Skip to content

BaseStorage

source

BaseStorage(
   observation_space: gym.Space, action_space: gym.Space, device: str,
   storage_size: int, batch_size: int, num_envs: int
)


Base class of the storage module.

Args

  • observation_space (gym.Space) : The observation space of environment.
  • action_space (gym.Space) : The action space of environment.
  • device (str) : Device (cpu, cuda, ...) on which the code should be run.
  • storage_size (int) : The size of the storage.
  • batch_size (int) : Batch size of samples.
  • num_envs (int) : The number of parallel environments.

Returns

Instance of the base storage.

Methods:

.to_torch

source

.to_torch(
   x: np.ndarray
)


Convert numpy array to torch tensor.

Args

  • x (np.ndarray) : Numpy array.

Returns

Torch tensor.

.reset

source

.reset()


Reset the storage.

.add

source

.add(
   *args, **kwargs
)


Add samples to the storage.

.sample

source

.sample(
   *args, **kwargs
)


Sample from the storage.

.update

source

.update(
   *args, **kwargs
)


Update the storage if necessary.