Skip to content

abstract_tensorizer

RL4CRN.env2agent_interface.abstract_tensorizer

Abstract tensorizer interface.

Defines the minimal interface for a tensorizer, a component that converts environment observations (typically produced by an observer) into PyTorch tensors suitable for neural network policies.

Tensorizers belong to the environment-to-agent (env2agent) interface and encapsulate device placement and any preprocessing needed to obtain the final tensor representation.

AbstractTensorizer

Base class for tensorizers mapping observations to torch tensors.

__init__(device='cpu')

Initialize the tensorizer.

PARAMETER DESCRIPTION
device

Target device for produced tensors (e.g., 'cpu', 'cuda').

DEFAULT: 'cpu'

tensorize(observation)

Convert an observation into a torch tensor representation.

Concrete tensorizers should override this method and document the expected structure of observation as well as the returned tensor shapes/dtypes.

PARAMETER DESCRIPTION
observation

Observation object produced by an observer.

RETURNS DESCRIPTION

A torch tensor (or a collection of tensors) placed on self.device.