OmniSafe Offline Data#
Data Collector#
Documentation
- class omnisafe.common.offline.OfflineDataCollector(size, env_name)[source]#
A class for collecting offline data.
Example
>>> # please change agent path and env name >>> env_name = 'SafetyPointCircle1-v0' >>> size = 2_000_000 >>> agents = [ >>> ('./runs/PPO', 'epoch-500', 1_000_000), >>> ('./runs/CPO', 'epoch-500', 1_000_000), >>> ] >>> save_dir = './data'
>>> col = OfflineDataCollector(size, env_name) >>> for agent, model_name, size in agents: >>> col.register_agent(agent, model_name, size) >>> col.collect(save_dir)
Initialize the data collector.
- Parameters:
size (int) – The total number of data to collect.
env_name (str) – The name of the environment.
Offline Dataset#
Documentation
- class omnisafe.common.offline.OfflineDataset(dataset_name, batch_size=256, gpu_threshold=1024, device=DEVICE_CPU)[source]#
A dataset for offline algorithms.
Initialize the dataset.
- Parameters:
dataset_name (
str
) –The name of the dataset. could be one of the following:
SafetyPointCircle1-v0_mixed_0.5
some local .npz file
batch_size (
int
) – The batch size of the dataset.gpu_threshold (
int
) – The threshold of size(MB) of the dataset to be loaded on GPU.device (
device
) – The device to load the dataset.
- class omnisafe.common.offline.OfflineDatasetWithInit(dataset_name, batch_size=256, gpu_threshold=1024, device=DEVICE_CPU)[source]#
A dataset with first observation in every episodes for offline algorithms.
Initialize the dataset.
- Parameters:
dataset_name (
str
) –The name of the dataset. could be one of the following:
SafetyPointCircle1-v0_mixed_0.5
some local .npz file
batch_size (
int
) – The batch size of the dataset.gpu_threshold (
int
) – The threshold of size(MB) of the dataset to be loaded on GPU.device (
device
) – The device to load the dataset.