Open jeev0306 opened 2 weeks ago
This looks like you're using an old version of Keras 3, from before the time when we supported nested model inputs.
Hi @jeev0306, Thanks for reporting the issue. Could you please share the version of Keras you are using and also dummy dataset to reproduce this issue?
import numpy as np import tensorflow as tf from tf_explain.core.grad_cam import GradCAM import matplotlib.pyplot as plt
Initialize Grad-CAM explainer
explainer = GradCAM()
Specify the layer for Grad-CAM in the VGG16 model (vgg16_tr)
conv_layer_name = 'block5_conv2' # Adjusted to use 'block5_conv2'
Get a batch from the validation generator
X_val, y_val = val_generator.getitem(0)
Process each image in the batch
for i in range(len(X_val)):
Add batch dimension to match the expected input shape for Grad-CAM
I'm trying to generate heatmaps using inbuilt GradCam function for the celebA dataset. But I get the below error. I have reviewed the size to the input going to the GradCam it is (1, 128,128,3).
error: When providing
inputs
as a list/tuple, all values in the list/tuple must be KerasTensors. Received: inputs=[[<KerasTensor shape=(None, 128, 128, 3), dtype=float32, sparse=None, name=keras_tensor>]] including invalid value [<KerasTensor shape=(None, 128, 128, 3), dtype=float32, sparse=None, name=keras_tensor>] of type <class 'list'>If anyone could help me debug this, it would be much appriciated.