d3rlpy.preprocessing.StandardObservationScaler

class d3rlpy.preprocessing.StandardObservationScaler(mean=None, std=None, eps=0.001)[source]

Standardization preprocessing.

\[x' = (x - \mu) / \sigma\]
from d3rlpy.preprocessing import StandardObservationScaler
from d3rlpy.algos import CQLConfig

# normalize based on datasets
cql = CQLConfig(observation_scaler=StandardObservationScaler()).create()

# manually initialize
mean = observations.mean(axis=0)
std = observations.std(axis=0)
observation_scaler = StandardObservationScaler(mean=mean, std=std)
cql = CQLConfig(observation_scaler=observation_scaler).create()
Parameters
  • mean (numpy.ndarray) – Mean values at each entry.

  • std (numpy.ndarray) – Standard deviation at each entry.

  • eps (float) – Small constant value to avoid zero-division.

Return type

None

Methods

classmethod deserialize(serialized_config)
Parameters

serialized_config (str) –

Return type

d3rlpy.serializable_config.TConfig

classmethod deserialize_from_dict(dict_config)
Parameters

dict_config (Dict[str, Any]) –

Return type

d3rlpy.serializable_config.TConfig

classmethod deserialize_from_file(path)
Parameters

path (str) –

Return type

d3rlpy.serializable_config.TConfig

fit_with_env(env)[source]

Gets scaling parameters from environment.

Parameters

env (gym.core.Env[Any, Any]) – Gym environment.

Return type

None

fit_with_trajectory_slicer(episodes, trajectory_slicer)[source]

Estimates scaling parameters from dataset.

Parameters
Return type

None

fit_with_transition_picker(episodes, transition_picker)[source]

Estimates scaling parameters from dataset.

Parameters
Return type

None

classmethod from_dict(kvs, *, infer_missing=False)
Parameters

kvs (Optional[Union[dict, list, str, int, float, bool]]) –

Return type

dataclasses_json.api.A

classmethod from_json(s, *, parse_float=None, parse_int=None, parse_constant=None, infer_missing=False, **kw)
Parameters

s (Union[str, bytes, bytearray]) –

Return type

dataclasses_json.api.A

static get_type()[source]
Return type

str

reverse_transform(x)[source]

Returns reversely transformed output.

Parameters

x (torch.Tensor) – input.

Returns

Inversely transformed output.

Return type

torch.Tensor

reverse_transform_numpy(x)[source]

Returns reversely transformed output in numpy.

Parameters

x (numpy.ndarray) – Input.

Returns

Inversely transformed output.

Return type

numpy.ndarray

classmethod schema(*, infer_missing=False, only=None, exclude=(), many=False, context=None, load_only=(), dump_only=(), partial=False, unknown=None)
Parameters
  • infer_missing (bool) –

  • many (bool) –

  • partial (bool) –

Return type

dataclasses_json.mm.SchemaF[dataclasses_json.api.A]

serialize()
Return type

str

serialize_to_dict()
Return type

Dict[str, Any]

to_dict(encode_json=False)
Return type

Dict[str, Optional[Union[dict, list, str, int, float, bool]]]

to_json(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, indent=None, separators=None, default=None, sort_keys=False, **kw)
Parameters
  • skipkeys (bool) –

  • ensure_ascii (bool) –

  • check_circular (bool) –

  • allow_nan (bool) –

  • indent (Optional[Union[int, str]]) –

  • separators (Optional[Tuple[str, str]]) –

  • default (Optional[Callable]) –

  • sort_keys (bool) –

Return type

str

transform(x)[source]

Returns processed output.

Parameters

x (torch.Tensor) – Input.

Returns

Processed output.

Return type

torch.Tensor

transform_numpy(x)[source]

Returns processed output in numpy.

Parameters

x (numpy.ndarray) – Input.

Returns

Processed output.

Return type

numpy.ndarray

Attributes

built
eps: float = 0.001
mean: Optional[numpy.ndarray] = None
std: Optional[numpy.ndarray] = None