nsl.lib.normalize
Stay organized with collections
Save and categorize content based on your preferences.
Normalizes the values in tensor
with respect to a specified vector norm.
nsl.lib.normalize(
tensor, norm_type, epsilon=1e-06
)
This op assumes that the first axis of tensor
is the batch dimension, and
calculates the norm over all other axes. For example, if tensor
is
tf.constant(1.0, shape=[2, 3, 4])
, its L2 norm (calculated along all the
dimensions other than the first dimension) will be [[sqrt(12)], [sqrt(12)]]
.
Hence, this tensor will be normalized by dividing by
[[sqrt(12)], [sqrt(12)]]
.
Note that tf.norm
is not used here since it only allows the norm to be
calculated over one axis, not multiple axes.
Args |
tensor
|
a tensor to be normalized. Can have any shape with the first axis
being the batch dimension that will not be normalized across.
|
norm_type
|
one of nsl.configs.NormType , the type of vector norm.
|
epsilon
|
a lower bound value for the norm to avoid division by 0.
|
Returns |
A normalized tensor with the same shape and type as tensor .
|
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."],[],[]]