21
21
import numpy as np
22
22
23
23
from tensorflow .python .keras import testing_utils
24
- from tensorflow .python .keras .utils import generic_utils
25
24
from tensorflow .python .platform import test
26
25
from tensorflow_addons .layers .python .poincare import PoincareNormalize
27
26
@@ -49,21 +48,17 @@ def testPoincareNormalize(self):
49
48
for dim in range (len (x_shape )):
50
49
outputs_expected = self ._PoincareNormalize (inputs , dim , epsilon )
51
50
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 )
67
62
68
63
def testPoincareNormalizeDimArray (self ):
69
64
x_shape = [20 , 7 , 3 ]
@@ -75,21 +70,17 @@ def testPoincareNormalizeDimArray(self):
75
70
76
71
outputs_expected = self ._PoincareNormalize (inputs , dim , epsilon )
77
72
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 )
93
84
94
85
95
86
if __name__ == '__main__' :
0 commit comments