ray.rllib.utils.tf_utils.l2_loss#

ray.rllib.utils.tf_utils.l2_loss(x: numpy.array | jnp.ndarray | tf.Tensor | torch.Tensor) numpy.array | jnp.ndarray | tf.Tensor | torch.Tensor[source]#

Computes half the L2 norm over a tensor’s values without the sqrt.

output = 0.5 * sum(x ** 2)

Parameters:

x – The input tensor.

Returns:

0.5 times the L2 norm over the given tensor’s values (w/o sqrt).