Skip to content

Commit

Permalink
add tanh activation
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoming0625 committed Apr 14, 2024
1 parent ca6fd53 commit 8b11e4b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions braintools/functional/_activations.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import braincore as bc

__all__ = [
"tanh",
"relu",
"squareplus",
"softplus",
Expand Down Expand Up @@ -60,6 +61,22 @@
'softmin',
]

def tanh(x: ArrayLike) -> jax.Array:
r"""Hyperbolic tangent activation function.
Computes the element-wise function:
.. math::
\mathrm{tanh}(x) = \frac{e^x - e^{-x}}{e^x + e^{-x}}
Args:
x : input array
Returns:
An array.
"""
return jnp.tanh(x)


def softmin(x, axis=-1):
r"""
Expand Down
1 change: 1 addition & 0 deletions docs/apis/functional.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Activation Functions
:nosignatures:
:template: classtemplate.rst

tanh
relu
squareplus
softplus
Expand Down

0 comments on commit 8b11e4b

Please sign in to comment.