3

I know that this example is supposed to illustrate how to add trainable parameters in a Python layer using the add_blob() method.

However, I am still unable to understand how this can be used to set the dimensions of the blob based on user defined parameters.

There is a better example here on how to write a Python layer here. But here, the layer does not contain any trainable parameters.

Please explain how to write a custom Python layer with trainable parameters.

Community
  • 1
  • 1
Suhas Lohit
  • 171
  • 8
  • I'm not sure what you mean by "set dimensions of the blob". AFAIK, caffe sets the top blob size based on the bottom blob size and properties of the current layer; so, you don't need to set the dimensions. – Amir Sep 13 '16 at 04:53

1 Answers1

0

When you add a parameters blob using add_blob(), you can reshape the added blob, either in setup() method (right when you add it), or in the layer's reshape() method.

Shai
  • 111,146
  • 38
  • 238
  • 371
  • Could you comment on how to let the layer have hyper-parameters that are user-defined in the train_val.prototxt file ? Also, are you required to make any changes in the caffe.proto or the header files when writing a custom Python layer? – Suhas Lohit Sep 13 '16 at 18:32