(path)
Split path into episodes and yield a deepcopy of each one
Split path into episodes and yield a deepcopy of each one
Split path into episodes and yield a deepcopy of each one
def split_path_by_episode(path):
    """Split path into episodes and yield a deepcopy of each one"""
    ep_breaks = np.where(path['new'])[0]
    start = ep_breaks[0]
    for end in ep_breaks[1:]:
        yield deepcopy({k: v[start:end] for k, v in path.items()
            if k in ['obs', 'actions', 'original_rewards', 'human_obs']})
        start = end
def split_path_by_episode ( path ) : ep_breaks = np . where ( path [ 'new' ] ) [ 0 ] start = ep_breaks [ 0 ] for end in ep_breaks [ 1 : ] : yield deepcopy ( { k : v [ start : end ] for k , v in path . items ( ) if k in [ 'obs' , 'actions' , 'original_rewards' , 'human_obs' ] } ) start = end