Certainly! Here’s a clear, step-by-step answer for your request:
1. Computational Graph Design
We’ll describe a many-to-one RNN :
It reads a sequence of inputs ((x_1, x_2, ..., x_T))
It has recurrent connections between hidden units
It produces a single output (y) after the last input
Graph Structure (Unrolled for 3 time steps):
code Copy code
x1 x2 x3
| | |
v v v
[+]--[+]--[+]
| | |
h1 h2 h3
|
v
[Output]
|
y
Each [+] is an RNN cell: it takes the current input and previous hidden state, outputs the new hidden state.
Only the final hidden state is used to compute the output.
2. Forward Propagation Equations
Let:
(x_t): input at time (t) ((d)-dimensional)
(h_t): hidden state at time (t) ((h)-dimensional)
(y): output ((o)-dimensional, often (o=1) for regression or binary classification)
(W_{xh}): input-to-hidden weights ((h \times d))
(W_{hh}): hidden-to-hidden weights ((h \times h))
(b_h): hidden bias ((h)-dimensional)
(W_{hy}): hidden-to-output weights ((o \times h))
(b_y): output bias ((o)-dimensional)
(\sigma): hidden activation (e.g., (\tanh) or ReLU)
(g): output activation (e.g., identity, sigmoid, softmax)
Initialization:
[
h_0 = 0
]
Recurrence (for (t = 1) to (T)):
[
a_t = W_{xh} x_t + W_{hh} h_{t-1} + b_h
]
[
h_t = \sigma(a_t)
]
Output (after last time step):
[
y = g(W_{hy} h_T + b_y)
]
3. Summary Table
Step Equation Init ( h_0 = 0 ) Recurrence ( a_t = W_{xh} x_t + W_{hh} h_{t-1} + b_h ) ( h_t = \sigma(a_t) ) Output ( y = g(W_{hy} h_T + b_y) )
4. Diagram (ASCII)
code Copy code
x1 -->[ ]--\
v
x2 -->[ ]--\
v
x3 -->[ ]--> h_T -->[Output Layer]--> y
Each [ ] is an RNN cell with recurrent connection from previous hidden state.
This is the standard RNN for sequence-to-single-output tasks (e.g., sentiment classification, sequence regression, etc.).