I am designing a CNN classifier for image classification with reproducibility. I am using the GPU of the Google Colab for this. To ensure the result is reproducible, I am enabling the TensorFlow ops deterministic using the "tf.config.experimental.enable_op_determinism()" command and getting the reproducible output. The problem is that when I am trying to create a gradient-based saliency map, I get an error. The error says,
"UnimplementedError: {{function_node _wrapped__FusedBatchNormGradV3_device/job:localhost/replica:0/task:0/device:GPU:0}} A deterministic GPU implementation of fused batch-norm backprop, when training is disabled, is not currently available. [Op:FusedBatchNormGradV3] name: "
Here is my code for creating the saliency map,
def salency_map(model, sample_index):
# Choose a random sample from the test set
#sample_index = np.random.randint(0, len(X_test))
sample_image = x_test[sample_index][np.newaxis]
#sample_image = x_test[sample_index]
sample_label = y_test[sample_index]
sample_class_index = np.argmax(sample_label)
Y_true = np.argmax(y_test[sample_index])
Y_pred_classes = np.argmax(model.predict(sample_image), axis=1)
print("Actual Class: ", labels[int(Y_true)])
print("Predicted Class: ", labels[int(Y_pred_classes)])
# Initialize GradCAM object
explainer = GradCAM()
# Explain the model predictions on the sample image
grid = explainer.explain((sample_image, None), model, class_index=sample_class_index)
# Visualize the saliency map
plt.figure(figsize=(4, 2))
plt.subplot(1, 2, 1)
plt.title("Original Image")
plt.imshow(sample_image.squeeze())
plt.subplot(1, 2, 2)
plt.title("Saliency Map")
plt.imshow(grid)
plt.colorbar()
plt.show()
How to overcome this issue?
After training the model, I tried to enable the non-deterministic mode again. But it did not work.