Neural network 在pycaffe中创建简单标识层后,网络不会收敛
这是一个简单的层,它可以将底部的水滴传递到顶部,而不做其他任何事情Neural network 在pycaffe中创建简单标识层后,网络不会收敛,neural-network,deep-learning,caffe,gradient-descent,pycaffe,Neural Network,Deep Learning,Caffe,Gradient Descent,Pycaffe,这是一个简单的层,它可以将底部的水滴传递到顶部,而不做其他任何事情 import caffe import numpy as np class MyCustomLayer(caffe.Layer): def setup(self, bottom, top): if len(bottom) != 1: raise Exception("Wrong number of bottom blobs") def forward(self, bottom, top):
import caffe
import numpy as np
class MyCustomLayer(caffe.Layer):
def setup(self, bottom, top):
if len(bottom) != 1:
raise Exception("Wrong number of bottom blobs")
def forward(self, bottom, top):
top[0].data[...] = bottom[0].data
def reshape(self, bottom, top):
top[0].reshape(*bottom[0].shape)
pass
def backward(self, propagate_down, bottom, top):
"""
This layer does not back propagate
"""
pass
但是,当在网络中使用时,网络将不会收敛,并将保持0.1
精度(而在使用此层之前,其精度为0.75%)我做错了什么 如果你不支持梯度,你希望你的网络如何收敛?您还需要实现
向后
:
def backward(self, top, propagate_down, bottom):
bottom[0].diff[...] = top[0].diff
请注意,backward()
的输入参数不同于其他方法,也不同于您在问题中所写的