add nn module for sigmoid activation (#111)

* add nn module for sigmoid activation

* update .gitignore with .cache folder generated by jetbrains fleet ide

* remove .cache folder
This commit is contained in:
Henry Ansah
2023-12-10 15:00:39 +00:00
committed by GitHub
parent 600db7d754
commit 68bf1d7867
2 changed files with 16 additions and 0 deletions

View File

@@ -15,6 +15,16 @@ def _make_activation_module(f):
return decorator
def sigmoid(x):
r"""Applies the element-wise function:
.. math::
\text{Sigmoid}(x) = \sigma(x) = \frac{1}{1 + \exp(-x)}
"""
return mx.sigmoid(x)
def relu(x):
"""Applies the Rectified Linear Unit.
@@ -79,6 +89,9 @@ def gelu_fast_approx(x):
"""
return x * mx.sigmoid(1.773 * x)
@_make_activation_module
class Sigmoid(Module):
pass
@_make_activation_module(relu)
class ReLU(Module):