All problems
Dreamer Latent Rollout
Problem
Roll a Dreamer recurrent latent state forward.
At each step h_next = tanh(W_h h + W_z z_t + W_a a_t + b) using the current latent h, the given stochastic latent z_t, and the action a_t. Return the trajectory including h0, so its length is len(z_seq) + 1.
Hint
The deterministic recurrent state carries memory while z captures per-step stochasticity.
Test cases
case 1
in: [[0],[[1],[0]],[[1],[0]],[[0.5]],[[1]],[[1]],[0]]
expected: [[0],[0.9640275800758169],[0.44785493732809273]]
case 2
in: [[0.5,-0.5],[[1,0]],[[0,1]],[[0,0.5],[0.5,0]],[[1,0],[0,1]],[[0.5,0.5],[0.5,0.5]],[0.1,-0.1]]
expected: [[0.5,-0.5],[0.874053287886007,0.5716699660851172]]
case 3
in: [[0],[[0.5],[1]],[[0],[1]],[[1]],[[0.5]],[[-1]],[0.25]]
expected: [[0],[0.46211715726000974],[0.2089920776832724]]
Starter codePython
import math
def dreamer_latent_rollout(h0, z_seq, a_seq, w_h, w_z, w_a, bias):
# Your code here
pass3 test cases · run your code against them in the editor