我想在使用Python圖層的Caffe中實現轉置功能。 以下是相同的代碼。在Caffe中實現「轉置」圖層的錯誤
但是,它拋出錯誤「在Reshape()
方法拋出的boost::python::error_already_set
實例終止後,調用。
有人能扔什麼,我做錯了一些輕?
import caffe
import numpy as np
class transpose(caffe.Layer):
def setup(self, bottom, top):
assert len(bottom) == 1, 'requires a single layer.bottom'
assert bottom[0].data.ndim == 2, 'requires matrix data'
assert len(top) == 1, 'requires a single layer.top'
def reshape(self, bottom, top):
top[0].reshape((bottom[0].data.shape[1], bottom[0].data.shape[0]))
def forward(self, bottom, top):
top[0].data = np.transpose(bottom[0].data)
def backward(self, top, propagate_down, bottom):
pass
謝謝, 。 Vijetha
[This](https://github.com/BVLC/caffe/issues/3594)是關於置換層的討論。這可能是相關的。該層的代碼可以在[這裏](https://github.com/intel/caffe/blob/master/src/caffe/layers/permute_layer.cpp)或[這裏](https://github.com/ BVLC/CAFFE /斑點/ b68695db42aa79e874296071927536363fe1efbf/SRC/CAFFE /層/ permute_layer.cpp)。 –
一個落後的傳球又如何轉置梯度? – Shai