All problems
Seq2Seq Encoder Final State
Problem
Return the final hidden state of a sequence encoder: given a list of per-timestep hidden vectors, return a copy of the last one.
The signature is encoder_final_state(hidden_states). This final state is what a seq2seq model passes to its decoder.
Hint
The encoder context is simply the last timestep's hidden vector.
Test cases
case 1
in: [[[[1,2],[3,4],[5,6]]]]
expected: [[1,2],[3,4],[5,6]]
case 2
in: [[[[1]]]]
expected: [[1]]
case 3
in: [[[[0,-1],[2,3]]]]
expected: [[0,-1],[2,3]]
case 4
in: [[[[1,2,3]]]]
expected: [[1,2,3]]
Starter codePython
def encoder_final_state(hidden_states):
# Your code here
pass4 test cases · run your code against them in the editor