observations

Contents

observations#


class ActionRewardDict[source]#
action: ndarray#
reward: ndarray#
class ActionRewardObservation(action_shape: tuple[int] = (4,))[source]#

Observation containing (normalized) action and a computed reward.

The reward is not extracted from the environment, but computed from the state. Thus, it could in principle be any scalar value, not necessarily a reward.

property action_shape: tuple[int]#
compute_observation(state: LabelmapStateAction) ActionRewardDict[source]#
property observation_space: MultiBoxSpace#
class ChanneledLabelmapsObsWithActReward[source]#

TypeDict for LabelmapSliceAsChannelsObservation.

  • channeled_slice: Boolean 3-d array representing segregated labelmap slice.

  • action: The last action taken.

  • reward: The reward received from the previous action.

action: ndarray#
channeled_slice: ndarray#
reward: ndarray#
class ClusterObservationDict[source]#
action: ndarray#
cluster_center_mean: ndarray#
num_clusters: ndarray#
num_points: ndarray#
reward: ndarray#
class ClusteringCharsDict[source]#
cluster_center_mean: ndarray#
num_clusters: ndarray#
num_points: ndarray#
class LabelmapClusterObservation[source]#

Observation for a flat array representation of a clustered labelmap slice.

compute_observation(state: LabelmapStateAction) ClusteringCharsDict[source]#

At the moment returns an array of len 3x4.

The result is: (num_clusters, num_points in all clusters, cluster_center_mean_x, cluster_center_mean_y) for each tissue type, where values are zero if there are no clusters.

property observation_space: MultiBoxSpace#
class LabelmapSliceAsChannelsObservation(slice_shape: tuple[int, int], action_shape: tuple[int])[source]#

Observation space for a labelmap slice, with each tissue type as a separate channel. The observation includes the current slice, the last action, and the last reward. Each observation is a dictionary of the type ChanneledLabelmapsObsWithActReward.

Parameters:

slice_shape -- slices will be cropped to this shape (we need a consistent observation space).

property action_shape: tuple[int]#
property channeled_slice_shape: tuple[int, int, int]#
compute_from_slice(labels_2d_slice: ndarray, action: ndarray) ChanneledLabelmapsObsWithActReward[source]#

Compute the observation from the labelmap slice, action, and reward and saves it in a dictionary of the form of ChanneledLabelmapsObsWithActReward.

compute_observation(state: LabelmapStateAction) ChanneledLabelmapsObsWithActReward[source]#

Return the observation as a dictionary of the type ChanneledLabelmapsObsWithActReward.

property observation_space: MultiBoxSpace#

Boolean 2-d array representing segregated labelmap slice.

property shape: tuple[tuple[int, int, int], tuple[int], tuple[int]]#
property slice_hw: tuple[int, int]#
class LabelmapSliceObservation(slice_shape: tuple[int, int], action_shape: tuple[int])[source]#

Observation space for a labelmap slice. To test performance diff between this and LabelmapSliceAsChannelsObservation.

Parameters:

slice_shape -- slices will be cropped to this shape (we need a consistent observation space).

property action_shape: tuple[int]#
compute_from_slice(labels_2d_slice: ndarray, action: ndarray) ChanneledLabelmapsObsWithActReward[source]#

Compute the observation from the labelmap slice, action, and reward and saves it in a dictionary of the form of ChanneledLabelmapsObsWithActReward.

compute_observation(state: LabelmapStateAction) ChanneledLabelmapsObsWithActReward[source]#

Return the observation as a dictionary of the type ChanneledLabelmapsObsWithActReward.

property observation_space: MultiBoxSpace#

Boolean 2-d array representing segregated labelmap slice.

property shape: tuple[tuple[int, int], tuple[int], tuple[int]]#
property slice_hw: tuple[int, int]#
property slice_shape: tuple[int, int]#
class MultiBoxSpace(name2box: dict[str, Box] | Dict)[source]#

The observation space is a dictionary, where each value's space is a Box. The observation space shape is a list of the shapes of each Box space. This class is a wrapper around gym.spaces.Dict, with additional methods to access the shape of each Box space, which as specified in gym.spaces.Dict needs special handling.

Parameters:

name2box -- dictionary of the name of the observation space and the Box space.

get_shape_from_name(name: str) Sequence[int][source]#

Get the shape of the Box space with the given name.

property name2box: dict[str, Box]#

Dictionary of the name of the observation space and the Box space.

sample(mask: dict[str, Any] | None = None) TDict[source]#

Generates a single random sample from this space.

The sample is an ordered dictionary of independent samples from the constituent spaces.

Args:

mask: An optional mask for each of the subspaces, expects the same keys as the space

Returns:

A dictionary with the same key and sampled values from self.spaces

property shape: list[Sequence[int]]#

Return the shape of the space as an immutable property. This is a special handling.