(batch, net, last_val_gamma, device="cpu")
return states_v, actions_v, ref_vals_v
Convert batch into training tensors
    :param batch:
    :param net:
    :return: states variable, actions tensor, reference values variable
Convert batch into training tensors
    :param batch:
    :param net:
    :return: states variable, actions tensor, reference values variable
Convert batch into training tensors : param batch : : param net : : return : states variable actions tensor reference values variable
def unpack_batch_continuous(batch, net, last_val_gamma, device="cpu"):
    """
    Convert batch into training tensors
    :param batch:
    :param net:
    :return: states variable, actions tensor, reference values variable
    """
    states = []
    actions = []
    rewards = []
    not_done_idx = []
    last_states = []
    for idx, exp in enumerate(batch):
        states.append(exp.state)
        actions.append(exp.action)
        rewards.append(exp.reward)
        if exp.last_state is not None:
            not_done_idx.append(idx)
            last_states.append(exp.last_state)
    states_v = ptan.agent.float32_preprocessor(states).to(device)
    actions_v = torch.FloatTensor(actions).to(device)

    # handle rewards
    rewards_np = np.array(rewards, dtype=np.float32)
    if not_done_idx:
        last_states_v = ptan.agent.float32_preprocessor(last_states).to(device)
        last_vals_v = net(last_states_v)[2]
        last_vals_np = last_vals_v.data.cpu().numpy()[:, 0]
        rewards_np[not_done_idx] += last_val_gamma * last_vals_np

    ref_vals_v = torch.FloatTensor(rewards_np).to(device)
    return states_v, actions_v, ref_vals_v
def unpack_batch_continuous ( batch , net , last_val_gamma , device = "cpu" ) : states = [ ] actions = [ ] rewards = [ ] not_done_idx = [ ] last_states = [ ] for idx , exp in enumerate ( batch ) : states . append ( exp . state ) actions . append ( exp . action ) rewards . append ( exp . reward ) if exp . last_state is not None : not_done_idx . append ( idx ) last_states . append ( exp . last_state ) states_v = ptan . agent . float32_preprocessor ( states ) . to ( device ) actions_v = torch . FloatTensor ( actions ) . to ( device ) # handle rewards rewards_np = np . array ( rewards , dtype = np . float32 ) if not_done_idx : last_states_v = ptan . agent . float32_preprocessor ( last_states ) . to ( device ) last_vals_v = net ( last_states_v ) [ 2 ] last_vals_np = last_vals_v . data . cpu ( ) . numpy ( ) [ : , 0 ] rewards_np [ not_done_idx ] += last_val_gamma * last_vals_np ref_vals_v = torch . FloatTensor ( rewards_np ) . to ( device ) return states_v , actions_v , ref_vals_v