访问Keras中自定义图层内的目标

时间:2017-11-14 21:46:56

标签: python keras keras-layer

我正在Keras写一个自定义图层,我想知道是否有办法访问图层内的目标值。

class Custom(Layer):
    def __init__(self, **kwargs):
        super(Custom, self).__init__(**kwargs)

    def build(self, input_shape):
        super(Custom, self).build(input_shape) 

    def call(self, x):
        result =  K.dot(x, self.kernel)
    targets = ???
        return result

    def compute_output_shape(self, input_shape):
        return (input_shape[0], self.output_dim)

现在我以前做的是使用占位符来存储和更新每个批次开始时的目标值。但现在我正在使用一个生成器,似乎在生成器中我无法调用Keras的set_value函数,所以我无法更新我的“目标占位符”

是否有任何巧妙的方法来访问自定义图层中的目标值?

0 个答案:

没有答案