Implementation and fine-tuning of an Independently Recurrent Neural Network (IndRNN) — a deep RNN architecture that overcomes gradient vanishing/exploding by keeping recurrent weights independent per neuron. Applied to sequence classification tasks.
Unlike standard RNNs where neurons share recurrent weights, IndRNN restricts each neuron to its own recurrent weight, enabling:
- ✅ Training of much deeper RNNs (10+ layers)
- ✅ Longer memory without gradient problems
- ✅ Faster convergence with batch normalization
flowchart LR
Input["xₜ"] --> Linear["W·xₜ"]
PrevH["hₜ₋₁"] --> Diag["diag(u)·hₜ₋₁\n(element-wise)"]
Linear --> Add["⊕"]
Diag --> Add
Add --> Act["ReLU"]
Act --> Output["hₜ"]
pip install -r requirements.txt
jupyter notebook IndRNN_Training.ipynbclass IndRNNCell(nn.Module):
def __init__(self, input_size, hidden_size):
super().__init__()
self.input_linear = nn.Linear(input_size, hidden_size)
self.recurrent_weight = nn.Parameter(torch.Tensor(hidden_size))
def forward(self, x, h):
return F.relu(self.input_linear(x) + h * self.recurrent_weight)| Model | Accuracy | Layers | Gradient Issues |
|---|---|---|---|
| LSTM | 91.2% | 2 | Minimal |
| Standard RNN | 78.4% | 2 | Vanishing |
| IndRNN | 94.1% | 6 | None |
MIT