这是一个很好的解决方法,但是如果您只想将
phaseas作为参数传递,现在可以将阶段作为图层的属性来访问。此功能仅在6天前合并https://github.com/BVLC/caffe/pull/3995。
具体提交:https
:
//github.com/BVLC/caffe/commit/de8ac32a02f3e324b0495f1729bff2446d402c2c
使用此新功能,您只需要使用属性
self.phase。例如,您可以执行以下操作:
class PhaseLayer(caffe.Layer):"""A layer for checking attribute `phase`"""def setup(self, bottom, top): passdef reshape(self, bootom, top): top[0].reshape()def forward(self, bottom, top): top[0].data[()] = self.phase



