Update normalization_test.py
@@ -200,13 +200,22 @@ class NormalizationTest(test_combinations.TestCase,
def test_invert(self):
data = np.array([0., 2., 0., 2.])
- layer = normalization.Normalization(mean=1.0, variance=1.0)
- layer2 = normalization.Normalization(mean=1.0, variance=1.0, invert=True)
- output = layer(data)
- output2 = layer2(output)
+ norm = normalization.Normalization(mean=1.0, variance=1.0)
+ inv_norm = normalization.Normalization(mean=1.0, variance=1.0, invert=True)
+ output = norm(data)
+ output2 = inv_norm(output)
self.assertListEqual(output2.shape.as_list(), [4])
self.assertAllClose(output2, [0., 2., 0., 2.])
+ def test_invert_adapt(self):
+ input_data = [[0.], [2.], [0.], [2.]]
+ norm = keras.layers.Normalization(axis=-1)
+ norm.adapt(input_data)
+ inv_norm = keras.layers.Normalization(axis=-1, invert=True)
+ inv_norm.adapt(input_data)
+ output = norm(input_data)
+ output2 = inv_norm(output)
+ self.assertAllClose(input_data, output2)
@test_combinations.run_all_keras_modes(always_skip_v1=True)
class NormalizationAdaptTest(test_combinations.TestCase,
