xavysp / TEED

TEED: Tiny and Efficient Edge Detector
MIT License
178 stars 17 forks source link

tensorflow Smish version #24

Open tomaszjacek opened 2 weeks ago

tomaszjacek commented 2 weeks ago

Mr. Professor,

When I'm trying


@tf.function def smish(input): return input * tf.math.tanh(tf.math.log(1+tf.math.sigmoid(input)))

class Smish(layers.Layer):

def __init__(self, input):
    """
    Init method.
    """
    super().__init__()

def call(self, input):
    """
    Forward pass of the function.
    """
    return smish(input)

than in model declaration

self_conv2D_11 = Conv2D(16 , kernel_size=(3,3),strides=(1,1),padding = 'same')

activation_9 = Smish(conv2D_1) conv2D_11 = self_conv2D_11(activation_9)

i got an error TypeError: Inputs to a layer should be tensors. Got: <main.Smish object at 0x000001F82C4FE910>

Would you be so kind to give hint how to translate Smish to tensorflow ?

Thank you, tj

tomaszjacek commented 1 week ago

it works, just need to change def init(self, input): to def init(self): and declare first self_activation_9 = Smish() than use it as activation_9 = self_activation_9(conv2D_1)