| 423 | """ |
| 424 | |
| 425 | def __init__( |
| 426 | self, act=None, epsilon=0.00001, beta_init=tl.initializers.zeros(), |
| 427 | gamma_init=tl.initializers.random_normal(mean=1.0, stddev=0.002), num_features=None, |
| 428 | data_format='channels_last', name=None |
| 429 | ): |
| 430 | super(InstanceNorm, self).__init__(name=name, act=act) |
| 431 | self.epsilon = epsilon |
| 432 | self.beta_init = beta_init |
| 433 | self.gamma_init = gamma_init |
| 434 | self.num_features = num_features |
| 435 | self.data_format = data_format |
| 436 | |
| 437 | if num_features is not None: |
| 438 | if not isinstance(self, InstanceNorm1d) and not isinstance(self, InstanceNorm2d) and not isinstance( |
| 439 | self, InstanceNorm3d): |
| 440 | raise ValueError( |
| 441 | "Please use InstanceNorm1d or InstanceNorm2d or InstanceNorm3d instead of InstanceNorm " |
| 442 | "if you want to specify 'num_features'." |
| 443 | ) |
| 444 | self.build(None) |
| 445 | self._built = True |
| 446 | |
| 447 | logging.info( |
| 448 | "InstanceNorm %s: epsilon: %f act: %s " % |
| 449 | (self.name, epsilon, self.act.__name__ if self.act is not None else 'No Activation') |
| 450 | ) |
| 451 | |
| 452 | def __repr__(self): |
| 453 | actstr = self.act.__name__ if self.act is not None else 'No Activation' |