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
NLDorLDwhere:Nis the optional batch dimensionLis the sequence lengthDis 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
NHorH, depending on whether the input is batched or not. Returns the hidden state at each time step, of shapeNLHorLH.- Parameters:
Methods