All problems
Seq2Seq Decoder Step
Problem
Compute one recurrent decoder step with a single weight: tanh(weight * hidden + x).
Return the new hidden value.
Hint
tanh squashes the pre-activation into (-1, 1).
Test cases
case 1
in: [0,1,0.5]
expected: 0.7615941559557649
case 2
in: [1,0,1]
expected: 0.7615941559557649
case 3
in: [0,0,0.5]
expected: 0
case 4
in: [1,1,0.5]
expected: 0.9051482536448664
Starter codePython
import math
def seq2seq_decoder_step(hidden, x, weight):
# Your code here
pass4 test cases · run your code against them in the editor