→ Recurrent neuron is different from dense layer. It does all the same things as a dense neuron, but with a twist: it also receives its own output from the previous step as an input.

Screenshot 2025-08-04 032824.png

→ Because an RNN processes sequences, we need a way to represent that sequence data. That's where the 3D input shape (batch_size, time_steps, features) comes from.

features (Dimension 3): This is the easiest. It's "how many data points describe the input at a single point in time?"

time_steps (Dimension 2): This is the length of your sequence. It's "how many consecutive points in time are you looking at to make one prediction?"

batch_size (Dimension 1): This is just for efficiency. It's "how many separate sequences are you feeding the network at once?"

So, an input shape of (32, 10, 1) for our stock example means: "The network is processing 32 different sequences, each 10 days long (time steps), where each day is described by 1 feature (the closing price)."

→ Single Neuron vs. Layer of Neurons (And Multiple Outputs)

A single recurrent neuron would process the sequence (e.g., 10 time steps) and at each step, it would output a single number (a scalar).

A layer of recurrent neurons (e.g., SimpleRNN(units=64)) is just a collection of these neurons working in parallel. So, instead of one neuron looping, you have 64 independent neurons. At each time step, each of the 64 neurons takes the input and its own previous state, and each produces one output number.

image.png

Therefore, the output of the layer at a single time step is not a single number, but a vector of 64 numbers.

This is where the "multiple outputs" idea comes in, controlled by a key parameter: return_sequences.