pantheonrl.common.trajsaver.TransitionsMinimal

class TransitionsMinimal(obs, acts)[source]

Bases: Dataset

This class is modified from HumanCompatibleAI’s imitation repo: https://github.com/HumanCompatibleAI/imitation/blob/master/src/imitation/ data/types.py

A Torch-compatible Dataset of obs-act transitions. This class and its subclasses are usually instantiated via imitation.data.rollout.flatten_trajectories. Indexing an instance trans of TransitionsMinimal with an integer i returns the i`th `Dict[str, np.ndarray] sample, whose keys are the field names of each dataclass field and whose values are the ith elements of each field value. Slicing returns a possibly empty instance of TransitionsMinimal where each field has been sliced.

Methods

read_transition

Construct TransitionsMinimal from file

write_transition

Write transition to a given file.

Attributes

obs

Previous observations.

acts

Actions.

Parameters:
  • obs (ndarray) –

  • acts (ndarray) –

acts: ndarray

Actions. Shape: (batch_size,) + action_shape.

obs: ndarray

Previous observations. Shape: (batch_size, ) + observation_shape. The i’th observation obs[i] in this array is the observation seen by the agent when choosing action acts[i]. obs[i] is not required to be from the timestep preceding obs[i+1].

classmethod read_transition(file, obs_space, act_space)[source]

Construct TransitionsMinimal from file

write_transition(file)[source]

Write transition to a given file.