mlx.nn.RNN#
- class RNN(input_size: int, hidden_size: int, bias: bool = True, nonlinearity: Callable | None = None)#
An Elman recurrent layer.
The input is a sequence of shape
NLD
orLD
where:N
is the optional batch dimensionL
is the sequence lengthD
is the input’s feature dimension
Concretely, for each element along the sequence length axis, this layer applies the function:
\[h_{t + 1} = \text{tanh} (W_{ih}x_t + W_{hh}h_t + b)\]The hidden state \(h\) has shape
NH
orH
, depending on whether the input is batched or not. Returns the hidden state at each time step, of shapeNLH
orLH
.- Parameters:
Methods