Set the mean to subtract for centering the data. Parameters ---------- in_ : which input to assign this mean. mean : mean ndarray (input dimensional or broadcastable)
(self, in_, mean)
| 234 | self.raw_scale[in_] = scale |
| 235 | |
| 236 | def set_mean(self, in_, mean): |
| 237 | """ |
| 238 | Set the mean to subtract for centering the data. |
| 239 | |
| 240 | Parameters |
| 241 | ---------- |
| 242 | in_ : which input to assign this mean. |
| 243 | mean : mean ndarray (input dimensional or broadcastable) |
| 244 | """ |
| 245 | self.__check_input(in_) |
| 246 | ms = mean.shape |
| 247 | if mean.ndim == 1: |
| 248 | # broadcast channels |
| 249 | if ms[0] != self.inputs[in_][1]: |
| 250 | raise ValueError('Mean channels incompatible with input.') |
| 251 | mean = mean[:, np.newaxis, np.newaxis] |
| 252 | else: |
| 253 | # elementwise mean |
| 254 | if len(ms) == 2: |
| 255 | ms = (1,) + ms |
| 256 | if len(ms) != 3: |
| 257 | raise ValueError('Mean shape invalid') |
| 258 | if ms != self.inputs[in_][1:]: |
| 259 | raise ValueError('Mean shape incompatible with input shape.') |
| 260 | self.mean[in_] = mean |
| 261 | |
| 262 | def set_input_scale(self, in_, scale): |
| 263 | """ |