c++neural-networkdeep-learningcaffedeep-dream

Caffe::net reshape


I am trying to implement deepdream in C++ in caffe(I want to run it in android). googlenet requires input of shape 224*224*3. In the ipython notebook of deepdream it shows src.reshape(1,3,h,w). Does this mean that only input blob is reshaped or it is propagated through the network? I tried calling the net.Reshape() in C++ and it resulted in:

F0307 01:27:24.529654 31857 inner_product_layer.cpp:64] Check failed: K_ == new_K 
(1024 vs. 319488) Input size incompatible with inner product parameters.

Shouldn't the network be reshaped too? If not what is the implication of just reshaping input blob? I am new to deep learning. So forgive me if it seems trivial.


Solution

  • changing the shape of the input requires reshaping of the entire net. Alas, there are some layer types that do not like to be reshaped. Specifically, "InnerProduct" layer: the number of trainable parameters of an inner product layer depends on the exact input shape and the output shape. Therefore a net with an "InnerProduct" layer cannot be reshaped.

    You can use methods described in the "net surgery" example to convert the inner product layers to equivalent convolutional layers (that can be reshaped).