Илья Ефимов Илья Ефимов - 4 months ago 137
Python Question

How to reshape layer in caffe with python?

It is possible to use

layer within a prototxt file.

However, trying to use it in python (using
NetSpec()
):

n.resh = L.Reshape(n.fc3, reshape_param={'shape':'{dim:1 dim:1 dim:64 dim:64}'})


I got nothing but error:


AttributeError: 'BlobShape' object has no attribute 'append'


Answer

Try:

n.resh = L.Reshape(n.fc3, reshape_param={'shape':{'dim': [1, 1, 64, 64]}})

Note that the shape vector [1, 1, 64, 64] is passed as a list and not as a string like in the prototxt syntax.

In fact, any entry defined as repeated in caffe.proto, should be considered as a list/vector when interfacing using NetSpec.

Comments