Python: Torch.nn.functional.normalize() Function

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)    
tensor([0.1826, 0.3651, 0.5477, 0.7303])


Read More: