basic_utils/utils.py
def compute_target(qf, path, gamma, double=False):
    """
    Compute the one step bootstrap target for DQN updating.

    Args:
        qf: the q value function
        path: the data paths for calculation. The result is also saved into it.
        gamma: discount factor
        double: whether to use the double network
    """
    next_observations = path['next_observation']
    not_dones = path['not_done']
    rewards = path['reward'] * (1 - gamma) if gamma < 0.999 else path['reward']
    if not double:
        y_targ = qf.predict(next_observations, target=True).max(axis=1)
    else:
        ty = qf.predict(next_observations).argmax(axis=1)
        y_targ = qf.predict(next_observations, target=True)[np.arange(next_observations.shape[0]), ty]
    path['y_targ'] = y_targ * not_dones * gamma + rewards

    Compute the one step bootstrap target for DQN updating.

    Args:
        qf: the q value function
        path: the data paths for calculation. The result is also saved into it.
        gamma: discount factor
        double: whether to use the double network
    
Compute the one step bootstrap target for DQN updating.
Compute the one step bootstrap target for DQN updating .
def compute_target(qf, path, gamma, double=False):
    next_observations = path['next_observation']
    not_dones = path['not_done']
    rewards = path['reward'] * (1 - gamma) if gamma < 0.999 else path['reward']
    if not double:
        y_targ = qf.predict(next_observations, target=True).max(axis=1)
    else:
        ty = qf.predict(next_observations).argmax(axis=1)
        y_targ = qf.predict(next_observations, target=True)[np.arange(next_observations.shape[0]), ty]
    path['y_targ'] = y_targ * not_dones * gamma + rewards
def compute_target ( qf , path , gamma , double = False ) : next_observations = path [ 'next_observation' ] not_dones = path [ 'not_done' ] rewards = path [ 'reward' ] * ( 1 - gamma ) if gamma < 0.999 else path [ 'reward' ] if not double : y_targ = qf . predict ( next_observations , target = True ) . max ( axis = 1 ) else : ty = qf . predict ( next_observations ) . argmax ( axis = 1 ) y_targ = qf . predict ( next_observations , target = True ) [ np . arange ( next_observations . shape [ 0 ] ) , ty ] path [ 'y_targ' ] = y_targ * not_dones * gamma + rewards
Compute the one step bootstrap target for DQN updating.
Compute the one step bootstrap target for DQN updating .
"""
    Compute the one step bootstrap target for DQN updating.

    Args:
        qf: the q value function
        path: the data paths for calculation. The result is also saved into it.
        gamma: discount factor
        double: whether to use the double network
    """
qf
the q value function
the q value function
path
the data paths for calculation. The result is also saved into it.
the data paths for calculation . The result is also saved into it .
gamma
None
double
whether to use the double network
whether to use the double network