Ex1

1. Rewrite the Problem

  • Vocabulary: ([‘i’, ‘o’, ‘c’, ‘a’])
  • Embeddings: ([-2, 5, 1, 9]) (so ‘i’→-2, ‘o’→5, ‘c’→1, ‘a’→9)
  • , ,
  • Elman RNN, activation (just identity), no bias

Task:

  • Compute forward through a simple 2-timestep RNN for input [‘o’, ‘c’] (i.e. embed ‘o’, then ‘c’).
  • At each step, follow the RNN equations for hidden states.
  • Compute the Loss as (details of loss not specified, but just follow the architecture for now).

2. Step-by-Step Solution:

Step 1: Initialization

  • (initial hidden state)

Step 2: First input (‘o’)

  • Embed ‘o’:
  • Elman RNN update:
  • Plug values:

Step 3: Second input (‘c’)

  • Embed ‘c’:
  • Elman RNN update:
  • Plug values:

(Optional) Step 4: Compute Output and Loss

  • Usually, there’s one last layer for outputs ()
  • For each time step:
  • Loss would be calculated here if target values were given. For now, just sum the losses at each step as in the diagram.

3. Summary Table

StepInputEmbeddingOutput
1‘o’505
2‘c’15

General formula:
At each :

That’s it!

  • Go forward step-by-step with the given embeddings and weights.
  • Use the RNN update each time.
  • Apply the output weight.
  • If you had targets (labels), you could then compute and with a loss function.