简体   繁体   中英

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' 

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM