- torchrl.envs.utils.check_env_specs(env, return_contiguous=True, check_dtype=True, seed=0)[source]¶
Tests an environment specs against the results of short rollout.
This test function should be used as a sanity check for an env wrapped with torchrl’s EnvBase subclasses: any discrepency between the expected data and the data collected should raise an assertion error.
A broken environment spec will likely make it impossible to use parallel environments.
env (EnvBase) – the env for which the specs have to be checked against data.
return_contiguous (bool, optional) – if
True, the random rollout will be called with return_contiguous=True. This will fail in some cases (e.g. heterogeneous shapes of inputs/outputs). Defaults to True.
check_dtype (bool, optional) – if False, dtype checks will be skipped. Defaults to True.
seed (int, optional) – for reproducibility, a seed is set.
Caution: this function resets the env seed. It should be used “offline” to check that an env is adequately constructed, but it may affect the seeding of an experiment and as such should be kept out of training scripts.