Skip to content

Commit 40c722b

Browse files
authored
Modify tests for pre-registered layer
1 parent f264c7d commit 40c722b

File tree

1 file changed

+22
-31
lines changed

1 file changed

+22
-31
lines changed

tensorflow_addons/layers/python/poincare_test.py

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import numpy as np
2222

2323
from tensorflow.python.keras import testing_utils
24-
from tensorflow.python.keras.utils import generic_utils
2524
from tensorflow.python.platform import test
2625
from tensorflow_addons.layers.python.poincare import PoincareNormalize
2726

@@ -49,21 +48,17 @@ def testPoincareNormalize(self):
4948
for dim in range(len(x_shape)):
5049
outputs_expected = self._PoincareNormalize(inputs, dim, epsilon)
5150

52-
with generic_utils.custom_object_scope({
53-
'PoincareNormalize':
54-
PoincareNormalize
55-
}):
56-
outputs = testing_utils.layer_test(
57-
PoincareNormalize,
58-
kwargs={
59-
'axis': dim,
60-
'epsilon': epsilon
61-
},
62-
input_data=inputs,
63-
expected_output=outputs_expected)
64-
for y in outputs_expected, outputs:
65-
norm = np.linalg.norm(y, axis=dim)
66-
self.assertLessEqual(norm.max(), 1. - epsilon + tol)
51+
outputs = testing_utils.layer_test(
52+
PoincareNormalize,
53+
kwargs={
54+
'axis': dim,
55+
'epsilon': epsilon
56+
},
57+
input_data=inputs,
58+
expected_output=outputs_expected)
59+
for y in outputs_expected, outputs:
60+
norm = np.linalg.norm(y, axis=dim)
61+
self.assertLessEqual(norm.max(), 1. - epsilon + tol)
6762

6863
def testPoincareNormalizeDimArray(self):
6964
x_shape = [20, 7, 3]
@@ -75,21 +70,17 @@ def testPoincareNormalizeDimArray(self):
7570

7671
outputs_expected = self._PoincareNormalize(inputs, dim, epsilon)
7772

78-
with generic_utils.custom_object_scope({
79-
'PoincareNormalize':
80-
PoincareNormalize
81-
}):
82-
outputs = testing_utils.layer_test(
83-
PoincareNormalize,
84-
kwargs={
85-
'axis': dim,
86-
'epsilon': epsilon
87-
},
88-
input_data=inputs,
89-
expected_output=outputs_expected)
90-
for y in outputs_expected, outputs:
91-
norm = np.linalg.norm(y, axis=tuple(dim))
92-
self.assertLessEqual(norm.max(), 1. - epsilon + tol)
73+
outputs = testing_utils.layer_test(
74+
PoincareNormalize,
75+
kwargs={
76+
'axis': dim,
77+
'epsilon': epsilon
78+
},
79+
input_data=inputs,
80+
expected_output=outputs_expected)
81+
for y in outputs_expected, outputs:
82+
norm = np.linalg.norm(y, axis=tuple(dim))
83+
self.assertLessEqual(norm.max(), 1. - epsilon + tol)
9384

9485

9586
if __name__ == '__main__':

0 commit comments

Comments
 (0)