-
Notifications
You must be signed in to change notification settings - Fork 18.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Input Layer to Replace input
s
#3211
Conversation
Some thoughts here: how to coordinate this with MemoryDataLayer? When should one use InputDataLayer and when to use MemoryDataLayer? For me, it seems we can set a guideline as follows: if you want to have a large input array that is going to be splitted into different batches, use MemoryDataLayer. Otherwise, use InputDataLayer. A side issue: we should also allow MemoryDataLayer to be compatible with ND-array (now they only handle 4D). I can handle the Matcaffe part of InputDataLayer interface (and MemoryDataLayer interface). |
Not that this should be an argument against an |
Quote from #1245
IMO, I hope to have a |
Thanks for this! 👍 I wouldn't say this fixes #1245 quite yet. You still need a third
Are you saying that the old |
Fair enough; I've only done part but I hope this can scaffold further work.
Instead of overloading
The old style input fields are upgraded automatically in 9698cc8 so those old defs will still work. "Net inputs are done away with entirely" means that there is no longer any notion of Net input blob in the code. There used to be special cases but now a Net is layers all the way down. |
Cool. |
635afe7
to
1de3988
Compare
be022f4
to
1c17de7
Compare
@jeffdonahue @longjon please check but this looks ready to do away with input fields so that Nets are composed of layers alone. I decided to leave |
1c17de7
to
6fbcad1
Compare
Ping? This combined with a PR to allow pycaffe to set the https://github.com/NVIDIA/DIGITS/blob/v3.2.0/digits/model/tasks/caffe_train.py#L579-L584 |
Create an input layer to replace oddball Net `input` fields.
Drop special cases for `input` fields, the `Net` input members, and the `Net` interface for Forward with bottoms along with Forward() / ForwardPrefilled() distinction.
Restore the list of net inputs for compatibility with the pycaffe and matcaffe interfaces and downstream C++.
6fbcad1
to
54794bc
Compare
@jeffdonahue @longjon this should finally be wrapped up if you can review -- I can squash 0d9a78f into 51f79a8 if desired because of the backtracking. |
54794bc
to
2cc3844
Compare
*/ | ||
const vector<Blob<Dtype>*>& ForwardPrefilled(Dtype* loss = NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO at least ForwardPrefilled
should be marked as deprecated and rewritten to just wrap around the new Forward
-- just removing it breaks Caffe for probably most anyone using it for inference in production. Not sure if something similar would be reasonable for the other Forward
methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept ForwardPrefilled()
and Forward(bottom, loss)
for now with deprecation.
Thanks @shelhamer, this simplifies a lot of code and LGTM besides the removal vs. deprecation issue of existing |
@jeffdonahue agreed, dropping the methods all at once is too jarring. I'll relax to a deprecation warning, although I do look forward to the day we can clear the old code. Thanks for the review! |
Tested and it's working for me 👍 For the curious, here's an example of how to read the input dimensions for network = caffe_pb2.NetParameter()
with open(deploy_file) as infile:
text_format.Merge(infile.read(), network)
dims = None
# Method 1 - Input layer
for layer in network.layer:
if layer.type == 'Input':
for top_index, top_name in enumerate(layer.top):
if top_name == 'data':
dims = layer.input_param.shape[top_index].dim
break
if dims is not None:
break
if dims is None:
# Method 2: network.input
for input_index, input_name in enumerate(network.input):
if input_name == 'data':
# Method 2a - input_shape.dim
if network.input_shape:
dims = network.input_shape[input_index].dim
# Method 2b - input_dim
else:
dims = network.input_dim[(4*input_index):(4*(input_index+1))]
print 'dims are:', ','.join(str(d) for d in dims) |
@lukeyeager or through pycaffe
which will be robust to the Caffe format version and input field vs. layer although of course this requires the computation + memory of instantiating the net. |
Oh good call, thanks. I can let reshape do the work for me. |
Relax removal of `Forward()` variations by deprecating instead.
123f2e2
to
f88073a
Compare
Add Input Layer to Replace `input`s
Add Input Layer to Replace `input`s
…affe#1245 and BVLC/caffe#3211 i.e. https://github.com/BVLC/caffe/blob/master/models/bvlc_reference_caffenet/deploy.prototxt Which is not to say that this page doesn't work anymore, it does for the example given.
Approaches a fix for #1245.
The
input
fields are oddball members of net definitions that require special case code to initialize and manipulate since they are not layers. They cannot be tied to a phase / stage / level nor can they be defined in NetSpec.InputLayer
has tops that are assignable like inputs. The layer is essentially a no-op that holds the data assigned to its tops.or in net spec
The input fields are translated to an input layer automagically.
As a next, more radical step the Forward + bottoms
ForwardPrefilled()
interface is done away with.Net
inputs are preserved by mapping toInput
layers instead.Although this looks like modestly less code, ~100 lines are trimmed from
Net
.Note that one can hack this behavior with a
DummyDataLayer
by beginning forward after the dummy but that was an unnecessary hassle.TODO
Net
inputs: yes (at least for now)Forward(bottoms)
:nodeprecatedadapt pycaffe + matcaffe: no need since keepingNet
inputs