| 817 | """ |
| 818 | |
| 819 | def __init__( |
| 820 | self, |
| 821 | act=None, |
| 822 | epsilon=1e-5, |
| 823 | beta_init=tl.initializers.constant(0.0), |
| 824 | gamma_init=tl.initializers.constant(1.0), |
| 825 | moving_mean_init=tl.initializers.zeros(), |
| 826 | # beta_init=tf.compat.v1.initializers.constant(0.0), |
| 827 | # gamma_init=tf.compat.v1.initializers.constant(1.0), |
| 828 | # moving_mean_init=tf.compat.v1.initializers.zeros(), |
| 829 | data_format='channels_last', |
| 830 | name=None, #'switchnorm', |
| 831 | ): |
| 832 | # super(SwitchNorm, self).__init__(prev_layer=prev_layer, act=act, name=name) |
| 833 | super().__init__(name, act=act) |
| 834 | self.epsilon = epsilon |
| 835 | self.beta_init = beta_init |
| 836 | self.gamma_init = gamma_init |
| 837 | self.moving_mean_init = moving_mean_init |
| 838 | self.data_format = data_format |
| 839 | |
| 840 | logging.info( |
| 841 | "SwitchNorm %s: epsilon: %f act: %s" % |
| 842 | (self.name, epsilon, self.act.__name__ if self.act is not None else 'No Activation') |
| 843 | ) |
| 844 | |
| 845 | def build(self, inputs_shape): |
| 846 | if len(inputs_shape) != 4: |