pythontensorflow

how can i fix a problem regarding problem regarding 'L1Dist.call()'


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

    def call(self, input_embedding, validation_img):
        return tf.math.abs(input_embedding - validation_img)

Signature of method 'L1Dist.call()' does not match signature of the base method in class'Layer'

how can i fix this problem?


Solution

  • I found the solution :

    class L1Dist(Layer):
        def __init__(self, **kwargs):
            super(L1Dist, self).__init__(**kwargs)
    
        def call(self, inputs, *args, **kwargs):
            input_embedding, validation_embedding = inputs
            return tf.math.abs(input_embedding - validation_embedding)
    

    Instead of having input_embedding and validation_embedding as separate parameters, the method now accepts a single inputs argument, which will be a tuple or list containing both embeddings. as per a tansorflow document and it matches with the base method. found in base_layer.py line 465. sorry i'm bad at explaining things.