Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tensorflow Smish version #24

Open
tomaszjacek opened this issue Nov 8, 2024 · 1 comment
Open

tensorflow Smish version #24

tomaszjacek opened this issue Nov 8, 2024 · 1 comment

Comments

@tomaszjacek
Copy link

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
Copy link
Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant