如何使用python重塑caffe中的图层?

How to reshape layer in caffe with python?

可以在 prototxt 文件中使用 "Reshape" 图层。
但是,尝试在 python 中使用它(使用 NetSpec()):

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

我除了错误什么都没有得到:

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

尝试:

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

请注意,形状向量 [1, 1, 64, 64] 作为列表传递,而不是像 prototxt 语法中那样作为字符串传递。

事实上,在 caffe.proto 中定义为 repeated 的任何条目在使用 NetSpec 连接时都应被视为 list/vector。