且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Caffe:如何获取 Python 层的相位?

更新时间:2023-02-26 18:35:25

这是一个很好的解决方法,但是如果您只对将 phase 作为参数传递感兴趣,现在您可以访问相作为图层的一个属性.此功能仅在 6 天前合并 https://github.com/BVLC/caffe/pull/3995.

This is a very good workaround, but if you are only interested in passing the phase as a parameter, now you can access the phase as an attribute of the layer. This feature was merged just 6 days ago https://github.com/BVLC/caffe/pull/3995.

具体提交:https://github.com/BVLC/caffe/commit/de8ac324b42f20400000一个>

Specific commit: https://github.com/BVLC/caffe/commit/de8ac32a02f3e324b0495f1729bff2446d402c2c

有了这个新功能,您只需要使用属性self.phase.例如,您可以执行以下操作:

With this new feature you just need to use the attribute self.phase. For example you can do the following:

class PhaseLayer(caffe.Layer):
"""A layer for checking attribute `phase`"""

def setup(self, bottom, top):
    pass

def reshape(self, bootom, top):
    top[0].reshape()

def forward(self, bottom, top):
    top[0].data[()] = self.phase