convert_to_torch¶
-
class
maze.perception.perception_utils.
convert_to_torch
(stats: Any, device: Optional[str], cast: Optional[torch.dtype], in_place: Union[bool, str])¶ Converts any struct to torch.Tensors.
- Parameters
stats – Any (possibly nested) struct, the values in which will be converted and returned as a new struct with all leaves converted to torch tensors.
device – ‘cpu’ or ‘cuda’, or None if it should stay the same
cast – the type the element should be cast to, or None if it should stay the same
in_place – specify if the operation should be done in_place, can be bool or ‘try’
- Returns
A new struct with the same structure as stats, but with all values converted to torch Tensor types.