mirror of
https://github.com/ml-explore/mlx.git
synced 2025-09-06 08:24:39 +08:00
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:
@@ -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):
|
||||
|
Reference in New Issue
Block a user