Recurrent Neural Network Calculation by hand by Tom Yeh

As you can see, this is a recurrent neural network. I want to understand how the calculations are being made. Please, be as detailed as possible no matter how simple or self-explanatory the calculations are. It would be much better if you can show the calculations on paper and upload its image. Also, please don't mind if the question seems too easy. I have to understand this, as it's part of my course work. I tried doing the calculations but I can't figure it out.

This image is taken from: https://www.linkedin.com/posts/tom-yeh_deeplearning-neuralnetworks-generativeai-activity-7142506286788620288-jLN4/


1 Answer 1


enter image description here

This is the RNN architecture. Image is taken from https://en.wikipedia.org/wiki/Recurrent_neural_network.

Here $U = B$, $V = A$, and $W = C$.

We are using ReLU as the activation function. $\phi(x) = max(0, x)$

Computing $y_1$

$x_1 = 3$, $h_1$ = $\phi(U.x_1 + V.h_0)$= $\phi \left ( \begin{bmatrix}1\\2\end{bmatrix} *3 + \begin{bmatrix}1&-1\\1&1\end{bmatrix}\begin{bmatrix}0 \\ 0\end{bmatrix} \right)=\begin{bmatrix}3 \\ 6\end{bmatrix}$

$y_1 = V.h_1 = \begin{bmatrix}-1 \ 1\end{bmatrix}* \begin{bmatrix}3\\6\end{bmatrix} = 3$

Computing $y_2$

$x_2 = 4$, $h_2$ = $\phi(U.x_2 + V.h_1)$= $\phi \left ( \begin{bmatrix}1\\2\end{bmatrix} *4 + \begin{bmatrix}1&-1\\1&1\end{bmatrix}\begin{bmatrix}3 \\ 6\end{bmatrix} \right)=\begin{bmatrix}1 \\ 17\end{bmatrix}$

$y_2 = V.h_2 = \begin{bmatrix}-1 \ 1\end{bmatrix}* \begin{bmatrix}1\\17\end{bmatrix} = 16$

You can compute $y_3$ and $y_4$ similarly.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .