我正在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函数,所以我无法更新我的“目标占位符”
是否有任何巧妙的方法来访问自定义图层中的目标值?