@@ -100,8 +100,12 @@ def test_keras_binary_classification_model(self, correlation_type):
100
100
inputs = tf .keras .layers .Input (shape = (128 ,))
101
101
outputs = tf .keras .layers .Dense (1 , activation = "sigmoid" )(inputs )
102
102
model = tf .keras .models .Model (inputs , outputs )
103
+ if hasattr (tf .keras .optimizers , "legacy" ):
104
+ optimizer = tf .keras .optimizers .legacy .Adam (learning_rate = 0.1 )
105
+ else :
106
+ optimizer = tf .keras .optimizers .Adam (learning_rate = 0.1 )
103
107
model .compile (
104
- optimizer = tf . keras . optimizers . Adam ( learning_rate = 0.1 ) ,
108
+ optimizer = optimizer ,
105
109
loss = "binary_crossentropy" ,
106
110
metrics = [metric ],
107
111
)
@@ -128,7 +132,7 @@ def test_keras_binary_classification_model(self, correlation_type):
128
132
tf .function (metric .update_state )(y , preds )
129
133
metric_value = tf .function (metric .result )()
130
134
scipy_value = self .scipy_corr [correlation_type ](preds [:, 0 ], y [:, 0 ])[0 ]
131
- np .testing .assert_almost_equal (metric_value , metric_history [- 1 ])
135
+ np .testing .assert_almost_equal (metric_value , metric_history [- 1 ], decimal = 5 )
132
136
np .testing .assert_almost_equal (metric_value , scipy_value , decimal = 2 )
133
137
134
138
@pytest .mark .parametrize ("correlation_type" , testing_types )
0 commit comments