Parameters: - state:<class 'torch.FloatTensor'> = tensor([0.])Both the initial state of the environment and the previous state. - action:<class 'torch.FloatTensor'> = tensor([0.])The action that was taken to transition from state to next_state - next_state:<class 'torch.FloatTensor'> = tensor([0.])Both the next state, and the last state in the environment - terminated:<class 'torch.BoolTensor'> = tensor([True])Represents an ending condition for an environment such as reaching a goal or ‘living long enough’ as described by the MDP. Good reference is: https://github.com/openai/gym/blob/39b8661cb09f19cb8c8d2f59b57417517de89cb0/gym/core.py#L151-L155 - truncated:<class 'torch.BoolTensor'> = tensor([True])Represents an ending condition for an environment that can be seen as an out of bounds condition either literally going out of bounds, breaking rules, or exceeding the timelimit allowed by the MDP. Good reference is: https://github.com/openai/gym/blob/39b8661cb09f19cb8c8d2f59b57417517de89cb0/gym/core.py#L151-L155’ - reward:<class 'torch.FloatTensor'> = tensor([0])The single reward for this step. - total_reward:<class 'torch.FloatTensor'> = tensor([0.])The total accumulated reward for this episode up to this step. - env_id:<class 'torch.LongTensor'> = tensor([0])The environment this step came from (useful for debugging) - proc_id:<class 'torch.LongTensor'> = tensor([0])The process this step came from (useful for debugging) - step_n:<class 'torch.LongTensor'> = tensor([0])The step number in a given episode. - episode_n:<class 'torch.LongTensor'> = tensor([0])The episode this environment is currently running through. - image:<class 'torch.FloatTensor'> = tensor([0.])Intended for display and logging only. If the intention is to use images for training an agent, then use a env wrapper instead.
Now we can generate a couple to send their a pytorch data loader.
from torchdata.dataloader2.dataloader2 import DataLoader2from torchdata.dataloader2.reading_service import MultiProcessingReadingServicefrom torchdata.dataloader2.graph import traverseimport torchdata.datapipes as dp
def seed_worker(worker_id): torch.manual_seed(0)def random_step_generator(): whileTrue: yield SimpleStep.random()pipe = dp.iter.IterableWrapper(random_step_generator(),deepcopy=False)pipe = pipe.batch(batch_size=3)g = torch.Generator()g.manual_seed(0)dl = DataLoader2( pipe, reading_service=MultiProcessingReadingService(num_workers=2,worker_init_fn=seed_worker))for o in dl:print(o)break
/opt/conda/lib/python3.7/site-packages/torch/utils/data/datapipes/iter/utils.py:44: UserWarning: The input iterable can not be deepcopied, please be aware of in-place modification would affect source data.
"The input iterable can not be deepcopied, "