神经网络-如何用python在caffe中重塑层



可以在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语法中那样作为字符串传递的。

事实上,在使用NetSpec进行接口时,caffe.proto中定义为repeated的任何条目都应被视为列表/向量。

最新更新