SimpleRNN Unrolled Over Time
Interactive lab
Try it: SimpleRNN Unrolled Over Time
How a SimpleRNN processes a sequence one timestep at a time, computing output_t = tanh(dot(W, input_t) + dot(U, state_t) + b) and carrying that output forward as the next state, and what return_sequences changes.
How it works
- Start with the state at zeros.
- At each timestep compute dot(W, input_t) and dot(U, state_t), then add the bias b.
- Apply tanh to get output_t.
- Carry output_t forward as the state for the next timestep, reusing the same W, U and b.
- Return every output_t (return_sequences=True) or only the last one.
Default run (10 steps): Sequence of 4 timesteps [1, 0.5, -1, 2]. The state starts as zeros [0, 0]; the same W, U and b are reused at every timestep. … return_sequences=True: the layer returns every output_t, a (4, 2) tensor.
Simplified: One input feature and two state units, a sequence of at most six numbers, weights typed in by hand rather than learned. Toy dimensions, not a full real model.
Educational simulation
Loading the simulation…