N Neurarch Architectures Models Checks Data Docs Open the app

Architectures / NLP/LLM

๐Ÿ”„ Simple RNN

Simple Recurrent Neural Network for sequence processing

From Elman (1990). Finding Structure in Time. Cognitive Science. This page is the graph, not the PDF: open it, edit it, verify it, export it.

Layers
4
Parameters
1.10M
Input
128 ร— 300
Output
128 ร— 10
Verifier
Clean

Every number on this page is computed from the graph by the same functions the app runs, not written by hand.

Open Simple RNN on the canvas Free, no account needed

When to pick it

Pick as a teaching reference. Real workloads should reach for LSTM/GRU or transformer โ€” vanilla RNN suffers from vanishing gradients on anything beyond ~50 steps.

Structure

4 layers. Output shapes are propagated from the input shape, batch dimension excluded.

LayerTypeParametersOutput shape
1InputInputshape=[128, 300]128 ร— 300
2LSTMLSTMhiddenSize=256, numLayers=2128 ร— 256
3LinearLinearoutFeatures=10128 ร— 10
4OutputOutput128 ร— 10

What the verifier says

The same 43 single-graph checks that run on every edit in the app, on this graph.

No finding. Shapes propagate end to end, every divisibility condition holds, and no advisory rule fires. See the checks.

The PyTorch it exports

Generated from the graph above.

# Architecture designed with Neurarch: https://neurarch.com
# PyTorch: compatible with Python 3.8+ and torch>=1.12
# Colab: pip install torch torchvision  (usually pre-installed)

import torch
import torch.nn as nn
import torch.nn.functional as F
from typing import Tuple

class SimpleRNN(nn.Module):
    def __init__(self):
        super().__init__()

        self.lstm_1 = nn.LSTM(300, 256, num_layers=2, batch_first=True)
        self.linear_1 = nn.Linear(256, 10)

    def forward(self, x):
        # Input shape: [128,300]
        lstm_lstm_1 = self.lstm_1(x)[0]
        linear_near_1 = self.linear_1(lstm_lstm_1)
        # Output
        return linear_near_1


if __name__ == '__main__':
    model = SimpleRNN()
    model.eval()

    x = torch.randn(1, 128, 300)  # (batch, channels, length)
    with torch.no_grad():
        output = model(x)

    print(f'Input  shape : {tuple(x.shape)}')
    print(f'Output shape : {tuple(output.shape)}')
    total = sum(p.numel() for p in model.parameters())
    trainable = sum(p.numel() for p in model.parameters() if p.requires_grad)
    print(f'Parameters   : {total:,} total, {trainable:,} trainable')

For agents

This architecture is machine-readable end to end. An agent can list the set, fetch this graph, edit it, and have the edit verified before any GPU time is spent.

Also in NLP/LLM

๐Ÿค– Transformer Block
Transformer encoder block
8 layers ยท 7.09M
๐Ÿ“– BERT Base
BERT-Base encoder โ€” bidirectional MHA
11 layers ยท 31.12M
๐Ÿง  GPT-2
GPT-2 Small โ€” causal transformer block
12 layers ยท 84.33M
๐Ÿฆ™ LLaMA-3 Block
LLaMA-3 decoder block โ€” GQA
10 layers ยท 702.55M