Skip to content

allenact.utils.spaces_utils#

[view_source]

flatdim#

flatdim(space)

[view_source]

Return the number of dimensions a flattened equivalent of this space would have.

Accepts a space and returns an integer. Raises NotImplementedError if the space is not defined in gym.spaces.

flatten#

flatten(space, torch_x)

[view_source]

Flatten data points from a space.

unflatten#

unflatten(space, torch_x)

[view_source]

Unflatten a concatenated data points tensor from a space.

torch_point#

torch_point(space, np_x)

[view_source]

Convert numpy space point into torch.

numpy_point#

numpy_point(space: gym.Space, torch_x: Union[int, torch.Tensor, OrderedDict, Tuple])

[view_source]

Convert torch space point into numpy.

action_list#

action_list(action_space: gym.Space, flat_actions: torch.Tensor) -> List[ActionType]

[view_source]

Convert flattened actions to list.

Assumes flat_actions are of shape [step, sampler, flatdim].