tf.keras.activations.swish
Stay organized with collections
Save and categorize content based on your preferences.
Swish activation function, swish(x) = x * sigmoid(x)
.
View aliases
Compat aliases for migration
See
Migration guide for
more details.
`tf.compat.v1.keras.activations.swish`
tf.keras.activations.swish(
x
)
Swish activation function which returns x*sigmoid(x)
.
It is a smooth, non-monotonic function that consistently matches
or outperforms ReLU on deep networks, it is unbounded above and
bounded below.
Example Usage:
a = tf.constant([-20, -1.0, 0.0, 1.0, 20], dtype = tf.float32)
b = tf.keras.activations.swish(a)
b.numpy()
array([-4.1223075e-08, -2.6894143e-01, 0.0000000e+00, 7.3105860e-01,
2.0000000e+01], dtype=float32)
Returns |
The swish activation applied to x (see reference paper for details).
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[],[],null,["# tf.keras.activations.swish\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/keras-team/keras/tree/v2.13.1/keras/activations.py#L252-L280) |\n\nSwish activation function, `swish(x) = x * sigmoid(x)`.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n\\`tf.compat.v1.keras.activations.swish\\`\n\n\u003cbr /\u003e\n\n tf.keras.activations.swish(\n x\n )\n\nSwish activation function which returns `x*sigmoid(x)`.\nIt is a smooth, non-monotonic function that consistently matches\nor outperforms ReLU on deep networks, it is unbounded above and\nbounded below.\n\n#### Example Usage:\n\n a = tf.constant([-20, -1.0, 0.0, 1.0, 20], dtype = tf.float32)\n b = tf.keras.activations.swish(a)\n b.numpy()\n array([-4.1223075e-08, -2.6894143e-01, 0.0000000e+00, 7.3105860e-01,\n 2.0000000e+01], dtype=float32)\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----|---------------|\n| `x` | Input tensor. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| The swish activation applied to `x` (see reference paper for details). ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Reference --------- ||\n|---|---|\n| \u003cbr /\u003e - [Ramachandran et al., 2017](https://arxiv.org/abs/1710.05941) ||\n\n\u003cbr /\u003e"]]