d3rlpy.preprocessing.MinMaxActionScaler

class d3rlpy.preprocessing.MinMaxActionScaler(minimum=None, maximum=None)[source]

Min-Max normalization action preprocessing.

Actions will be normalized in range [-1.0, 1.0].

\[a' = (a - \min{a}) / (\max{a} - \min{a}) * 2 - 1\]
from d3rlpy.preprocessing import MinMaxActionScaler
from d3rlpy.algos import CQLConfig

# normalize based on datasets or environments
cql = CQLConfig(action_scaler=MinMaxActionScaler()).create()

# manually initialize
minimum = actions.min(axis=0)
maximum = actions.max(axis=0)
action_scaler = MinMaxActionScaler(minimum=minimum, maximum=maximum)
cql = CQLConfig(action_scaler=action_scaler).create()
Parameters:

Methods

classmethod deserialize(serialized_config)
Parameters:

serialized_config (str) –

Return type:

TConfig

classmethod deserialize_from_dict(dict_config)
Parameters:

dict_config (Dict[str, Any]) –

Return type:

TConfig

classmethod deserialize_from_file(path)
Parameters:

path (str) –

Return type:

TConfig

fit_with_env(env)[source]

Gets scaling parameters from environment.

Parameters:

env (Union[Env[Any, Any], 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:

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:

A

static get_type()[source]
Return type:

str

reverse_transform(x)[source]

Returns reversely transformed output.

Parameters:

x (Tensor) – input.

Returns:

Inversely transformed output.

Return type:

Tensor

reverse_transform_numpy(x)[source]

Returns reversely transformed output in numpy.

Parameters:

x (ndarray[Any, dtype[Any]]) – Input.

Returns:

Inversely transformed output.

Return type:

ndarray[Any, dtype[Any]]

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:

SchemaF[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:
Return type:

str

transform(x)[source]

Returns processed output.

Parameters:

x (Tensor) – Input.

Returns:

Processed output.

Return type:

Tensor

transform_numpy(x)[source]

Returns processed output in numpy.

Parameters:

x (ndarray[Any, dtype[Any]]) – Input.

Returns:

Processed output.

Return type:

ndarray[Any, dtype[Any]]

Attributes

built
maximum: Optional[ndarray[Any, dtype[Any]]] = None
minimum: Optional[ndarray[Any, dtype[Any]]] = None