MCPcopy Create free account
hub / github.com/XLearning-SCU/2022-CVPR-DART / normalize

Function normalize

loss.py:18–26  ·  view source on GitHub ↗

Normalizing to unit length along the specified dimension. Args: x: pytorch Variable Returns: x: pytorch Variable, same shape as input

(x, axis=-1)

Source from the content-addressed store, hash-verified

16
17
18def normalize(x, axis=-1):
19 """Normalizing to unit length along the specified dimension.
20 Args:
21 x: pytorch Variable
22 Returns:
23 x: pytorch Variable, same shape as input
24 """
25 x = 1. * x / (torch.norm(x, 2, axis, keepdim=True).expand_as(x) + 1e-12)
26 return x
27
28
29class TripletLoss_WRT(nn.Module):

Callers 2

forwardMethod · 0.85
forwardMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected