torch.nn.functional.normalize() Function Interpretation

Function action

The input data (tensor) for the specified dimensions of L2_ Normal operation.

Code examples

 import torch.nn.functional as F
>>> a=torch.tensor([1,2,3,4],dtype=torch.float32)
>>> a
tensor([1., 2., 3., 4.])
>>> F.normalize(a,p=2,dim=0)     #Perform operations on the specified dimension
tensor([0.1826, 0.3651, 0.5477, 0.7303])

Read More: