From 851ca160f7c38e9effd9e60bcd44b6611073ae60 Mon Sep 17 00:00:00 2001 From: Aditya Kane Date: Fri, 24 Dec 2021 12:41:05 +0530 Subject: [PATCH] Compat change in applications_load_weight_test --- keras/applications/applications_load_weight_test.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/keras/applications/applications_load_weight_test.py b/keras/applications/applications_load_weight_test.py index 372d0c4cf91..2aadae86b52 100644 --- a/keras/applications/applications_load_weight_test.py +++ b/keras/applications/applications_load_weight_test.py @@ -125,7 +125,10 @@ def test_application_pretrained_weights_loading(self): self.assertShapeEqual(model.output_shape, (None, _IMAGENET_CLASSES)) x = _get_elephant(model.input_shape[1:3]) x = app_module.preprocess_input(x) - preds = model(x).numpy() + try: + preds = model.predict(x) # Works in TF1 + except: + preds = model(x).numpy() # Works in TF2 names = [p[1] for p in app_module.decode_predictions(preds)[0]] # Test correct label is in top 3 (weak correctness test). self.assertIn('African_elephant', names[:3])