tf_agents.utils.tensor_normalizer.TensorNormalizer

Encapsulates tensor normalization and owns normalization variables.

Example usage:

tensor_normalizer = StreamingTensorNormalizer(
    tf.TensorSpec([], tf.float32))
observation_list = [list of float32 scalars or batches]
normalized_list = []

for o in observation_list:
  normalized_list.append(tensor_normalizer.normalize(o))
  tensor_normalizer.update(o)

Methods

normalize

View source

Applies normalization to tensor.

Args
tensor Tensor to normalize.
clip_value Clips normalized observations between +/- this value if clip_value > 0, otherwise does not apply clipping.
center_mean If true, subtracts off mean from normalized tensor.
variance_epsilon Epsilon to avoid division by zero in normalization.

Returns
normalized_tensor Tensor after applying normalization.

update

View source

Updates tensor normalizer variables.