J'écris une couche caffe python qui revend l'entrée entre [0 255] le long d'un axe spécifique (code attaché) et la passe avant fonctionne bien. Le passage vers l'arrière est-il requis pour une telle couche? si oui, comment puis-je l'implémenter?Caffe python backword passe la mise en œuvre
caffe_root = 'caffe_root'
import sys
sys.path.insert(0, caffe_root + 'python')
import caffe
import numpy as np
class scale_layer(caffe.Layer):
def setup(self, bottom, top):
assert len(bottom)==1 and len(top)==1, "scale_layer expects a single input and a single output"
def reshape(self, bottom, top):
top[0].reshape(*bottom[0].data.shape)
def forward(self, bottom, top):
in_ = np.array(bottom[0].data)
x_min = in_.min(axis=(0, 1), keepdims=True)
x_max = in_.max(axis=(0, 1), keepdims=True)
top[0].data[...] = np.around(255*((in_-x_min)/(x_max-x_min)))
def backward(self, top, propagate_down, bottom):
# backward pass is not implemented!
???????????????????????????
pass
pourquoi np.around? Comment envisagez-vous de différencier cela? – Shai
Pensez-vous à une solution de contournement pour faire le np.around? – Mak
l'ignore complètement? – Shai