GRUCell
¶
Bases: Module
A gated recurrent unit cell with the parameters and initialization of
torch.nn.GRUCell.
\[
\begin{aligned}
r &= \sigma(W_{ir} x + b_{ir} + W_{hr} h + b_{hr}) \\
z &= \sigma(W_{iz} x + b_{iz} + W_{hz} h + b_{hz}) \\
n &= \tanh(W_{in} x + b_{in} + r \odot (W_{hn} h + b_{hn})) \\
h' &= (1 - z) \odot n + z \odot h
\end{aligned}
\]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_dim
|
int
|
Size of the input |
required |
hidden_dim
|
int
|
Size of the hidden state |
required |
bias
|
bool
|
Whether to use biases. Default: |
True
|
Methods:
| Name | Description |
|---|---|
reset_parameters |
Draws all parameters from \(U(-1/\sqrt{H}, 1/\sqrt{H})\). |
__call__ |
Computes one step. |
Source code in mlx_graphs/nn/models/tgn.py
reset_parameters
¶
Draws all parameters from \(U(-1/\sqrt{H}, 1/\sqrt{H})\).
Source code in mlx_graphs/nn/models/tgn.py
__call__
¶
Computes one step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
array
|
Inputs, shape |
required |
h
|
array
|
Hidden states, shape |
required |
Returns:
| Type | Description |
|---|---|
array
|
The new hidden states, shape |
Source code in mlx_graphs/nn/models/tgn.py
from mlx_graphs.nn.models.tgn import GRUCell · mlx_graphs/nn/models/tgn.py