|View source on GitHub|
Projects batched tensors to a ball with the given radius in the given norm.
nsl.lib.project_to_ball( tensors, radius, norm_type, epsilon=1e-06 )
For each example in the batch, its global norm (across all tensors) will be clipped to the given raidus. If its global norm is already smaller or equal to the given radius, its values won't be changed.
Only L-infinity and L2 norms are currently supported.
||A (nested) collection of batched tensors to project to the given ball. The first dimension of each tensor is the batch size and must all be equal.|
||the radius of the ball.|
||Used to avoid division by 0.|
|A collection of tensors in the same structure as the input, projected to the given ball.|