DQN Targets with a Target Network
~16 mincode completion
Implement dqn_targets_and_loss(rewards, dones, q_target_next, q_online, actions, gamma) returning one array: the B targets followed by the loss, so it has length B+1.
Where this shows up
~16 min
••••••••••••
6 employers weight this skill
4 autonomy companies, 2 defense companies. Top match scores 87.
Python
import numpy as np
def dqn_targets_and_loss(rewards, dones, q_target_next, q_online, actions, gamma):
"""
DQN regression targets from a target network, and the TD loss.
Args:
rewards: (B,) reward of each transition
dones: (B,) 1 if the episode ended on this transition, else 0
q_target_next: (B, A) target-network Q-values at the next state s'
q_online: (B, A) online-network Q-values at the current state s
actions: (B,) index of the action taken in s
gamma: discount factor
Returns:
(B + 1,) array: [y_1, ..., y_B, loss]
"""
# YOUR CODE HERE
pass