MCPcopy Create free account
hub / github.com/DeepGraphLearning/S3F / _norm_no_nan

Function _norm_no_nan

s3f/gvp_layer.py:55–62  ·  view source on GitHub ↗

L2 norm of tensor clamped above a minimum value `eps`. :param sqrt: if `False`, returns the square of the L2 norm

(x, axis=-1, keepdims=False, eps=1e-8, sqrt=True)

Source from the content-addressed store, hash-verified

53
54
55def _norm_no_nan(x, axis=-1, keepdims=False, eps=1e-8, sqrt=True):
56 '''
57 L2 norm of tensor clamped above a minimum value `eps`.
58
59 :param sqrt: if `False`, returns the square of the L2 norm
60 '''
61 out = torch.clamp(torch.sum(torch.square(x), axis, keepdims), min=eps)
62 return torch.sqrt(out) if sqrt else out
63
64
65def _split(x, nv):

Callers 2

forwardMethod · 0.85
forwardMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected