Prediction in Caffe - Exception: Input blob arguments do not match net inputs

后端 未结 4 1088
忘了有多久
忘了有多久 2021-02-14 02:02

I\'m using Caffe for classifying non-image data using a quite simple CNN structure. I\'ve had no problems training my network on my HDF5-data with dimensions n x 1 x 156 x 12. H

4条回答
  •  旧巷少年郎
    2021-02-14 02:39

    Even small hints would be greatly appreciated!
    

    I am stuck too so not much help, sorry. Might want to skip to the end.

    net.inputs is a @property function which supposedly generated the names of the input layer(s).

    @property
    def _Net_inputs(self):
        return [list(self.blobs.keys())[i] for i in self._inputs]
    

    Where list(self.blobs.keys()) for you would be

    ['data', 'feature_conv', 'conv1', 'pool1', 'conv2', 'fc1', 'accuracy', 'loss']
    

    Since inputs has to match kwargs.keys() = ['data'] we can conclude that net._inputs should have been [0]. Somehow.

    Since _inputs isn't used anywhere else in pycaffe.py I have a look at _caffe.cpp. Around line 222 it says

    .add_property("_inputs", p::make_function(&Net::input_blob_indices,
        bp::return_value_policy()))
    

    So _inputs are the input_blob_indices and it makes sense that these should be [0] for your network.

    input_blob_indices in turn is simply a function that returns net_input_blob_indices_ in include/caffe/net.hpp

    inline const vector& input_blob_indices() const { return net_input_blob_indices_; }
    

    ...which is only used in src/caffe/net.cpp, but I can't find it being defined or assigned anywhere.

    I have tried with type: Data and type: MemoryData but that doesn't make a difference. What does work is using

    input: "data"
    input_dim: 1
    input_dim: 3
    input_dim: 227
    input_dim: 227
    

    ...instead of a layer. In that case net._inputs = [0] and net.inputs = ['data'] (actually net._inputs is a caffe._caffe.IntVec object but list(net._inputs) = [0]).

    TLDR: It is starting to look a lot like a bug so I submitted it: https://github.com/BVLC/caffe/issues/2246

    P.s. it seems like you are converting ndarray to datum and then back again. Does this have a purpose?

提交回复
热议问题