nsl.lib.project_to_ball
Stay organized with collections
Save and categorize content based on your preferences.
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.
Args |
tensors
|
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.
|
radius
|
the radius of the ball.
|
norm_type
|
One of nsl.configs.NormType . Currently L1 norm is not
supported.
|
epsilon
|
Used to avoid division by 0.
|
Returns |
A collection of tensors in the same structure as the input, projected to the
given ball.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2022-10-28 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2022-10-28 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2022-10-28 UTC."],[],[]]