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

Silu simpler #19417

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions keras/backend/tensorflow/nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def softsign(x):
return tf.nn.softsign(x)


def silu(x, beta=1.0):
return tf.nn.silu(x, beta=beta)
def silu(x):
return tf.nn.silu(x)


def log_sigmoid(x):
Expand Down
4 changes: 2 additions & 2 deletions keras/backend/torch/nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def softsign(x):
return tnn.softsign(x)


def silu(x, beta=1.0):
def silu(x):
x = convert_to_tensor(x)
return x * sigmoid(beta * x)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep the beta argument around, and only use the tnn implementation when beta == 1?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to expose it? The weird part was that this didn't exist on the actual keras.ops signature or jax or numpy.

That backend should match the ops signature right? We don't want secret extra options handing around on specific backends.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's not in the op signature we can drop it.

return tnn.silu(x)


def log_sigmoid(x):
Expand Down