MCPcopy Create free account
hub / github.com/FreeformRobotics/OTS / handy_var

Function handy_var

lib/nn/modules/tests/test_numeric_batchnorm.py:18–26  ·  view source on GitHub ↗
(a, unbias=True)

Source from the content-addressed store, hash-verified

16
17
18def handy_var(a, unbias=True):
19 n = a.size(0)
20 asum = a.sum(dim=0)
21 as_sum = (a ** 2).sum(dim=0) # a square sum
22 sumvar = as_sum - asum * asum / n
23 if unbias:
24 return sumvar / (n - 1)
25 else:
26 return sumvar / n
27
28
29class NumericTestCase(TorchTestCase):

Callers 1

testNumericBatchNormMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected