Rate this Page
★ ★ ★ ★ ★

TensorDictBase.clamp_max#

TensorDictBase.clamp_max_(other: TensorCollection | Tensor) → Self#

Clamps every leaf to at most other in place and returns self.

The in-place version of clamp_max(). It has no default: a tensordict other must have every key of the tensordict, and its other keys are ignored.

Parameters:

other (TensorDictBase, Tensor or Number) – the upper bound, paired with the leaves as in clamp_max(). A tensor is aligned with the batch dimensions of each leaf, except when a leaf is an UnbatchedTensor or inside a torch.func transform such as torch.vmap(): then every leaf broadcasts with it from the right, as in torch.

Every tensordict class and every tensorclass has this method. For the other methods, see Methods by task.