(batch_norm, axes)
| 143 | |
| 144 | |
| 145 | def 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 | |
| 165 | def custom_stddev(batch_norm, axes): |
no test coverage detected