Илья Ефимов
Илья Ефимов

Reputation: 128

How to reshape layer in caffe with python?

It is possible to use "Reshape" 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'

Upvotes: 1

Views: 1999

Answers (1)

Shai
Shai

Reputation: 114866

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.

Upvotes: 3

Related Questions