From b9dde7c1cfad778ca6a60c27a75da7d7d311ea50 Mon Sep 17 00:00:00 2001 From: J-Olejnik <108056647+J-Olejnik@users.noreply.github.com> Date: Mon, 3 Jun 2024 12:37:27 +0200 Subject: [PATCH] Updates for Keras 3.0 --- tf_explain/core/grad_cam.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tf_explain/core/grad_cam.py b/tf_explain/core/grad_cam.py index 3396a39..7374499 100644 --- a/tf_explain/core/grad_cam.py +++ b/tf_explain/core/grad_cam.py @@ -83,7 +83,7 @@ def infer_grad_cam_target_layer(model): """ for layer in reversed(model.layers): # Select closest 4D layer to the end of the network. - if len(layer.output_shape) == 4: + if len(layer.output.shape) == 4: return layer.name raise ValueError( @@ -108,7 +108,7 @@ def get_gradients_and_filters( Tuple[tf.Tensor, tf.Tensor]: (Target layer outputs, Guided gradients) """ grad_model = tf.keras.models.Model( - [model.inputs], [model.get_layer(layer_name).output, model.output] + model.inputs, [model.get_layer(layer_name).output, model.output] ) with tf.GradientTape() as tape: