6

I am writing a custom layer in Keras and I wonder if there is a way to access the target values inside the layer.

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)

Now what I have done previously is to use a placeholder to store and update the target values at the begining of each batch. But now I am using a generator and it seems that inside a generator I cannot call the set_value function of Keras so I cant update my "target placeholder"

Is there any neat way to access the target value in the custom layer?

DalekSupreme
  • 1,493
  • 3
  • 19
  • 32

0 Answers0