如何为两个顶级blob的caffe python层编写一个向后函数?

时间:2017-07-29 16:13:26

标签: neural-network deep-learning caffe gradient-descent pycaffe

在ubuntu 16.04上安装caffe之后。我成功地训练了cifar10-quick模型,然后我添加了一个简单的python层,如下所示:

import caffe
import numpy as np

class My_Custom_Layer(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)        

    def backward(self, top, propagate_down, bottom):
        bottom[0].diff[...] = top[0].diff

现在我想添加另一个top blob,top [1]并在bottom [0]中进行一些更改,但我不知道如何更改向后功能!

0 个答案:

没有答案