MCPcopy Create free account
hub / github.com/NVIDIA/DALI / custom_mean

Function custom_mean

dali/test/python/operator_1/test_normalize.py:145–162  ·  view source on GitHub ↗
(batch_norm, axes)

Source from the content-addressed store, hash-verified

143
144
145def custom_mean(batch_norm, axes):
146 bias = 0.3 # make the result purposefully slightly off
147 if type(axes) is list:
148 axes = tuple(axes)
149 if batch_norm:
150
151 def whole_batch_mean(batch):
152 out = batch_mean(batch, axes) + bias
153 return [out.astype(np.float32) for _ in range(len(batch))]
154
155 return whole_batch_mean
156 else:
157
158 def per_sample_mean(batch):
159 ret = [x.mean(axis=axes, keepdims=True, dtype=np.float32) + bias for x in batch]
160 return ret
161
162 return per_sample_mean
163
164
165def custom_stddev(batch_norm, axes):

Callers 3

custom_stddevFunction · 0.85
__init__Method · 0.85
check_batchMethod · 0.85

Calls 1

typeFunction · 0.50

Tested by

no test coverage detected