Does gradCAM work on 3D image inputs?

6 views (last 30 days)
Khuhed Memon
Khuhed Memon on 17 Oct 2024
Edited: Walter Roberson on 21 Oct 2024
I have 3D MRI volume in a 256x256x49 uint8 array. The same is the input expectation of my model.
[class,score]=classify(trainedNetwork_1,MRI)
The above statement runs fine, with output:
class =
categorical
MS
score =
1×2 single row vector
0.6391 0.3609
but the following function throws an error:
gradCamMap=gradCAM(trainedNetwork_1,MRI,class);
Error using gradCAM (line 144)
Index exceeds the number of array elements. Index must not exceed 2.
What am I doing wrong here?

Answers (1)

Hitesh
Hitesh on 21 Oct 2024
Edited: Hitesh on 21 Oct 2024
From what I understand is that if your model has multiple classes, ensure that the index you are passing to "gradCAM" corresponds to the correct class index. You need to convert the categorical class label to an index. Kindly refer to the below code for an example:
classIndex = find(class == categories(class)); % Example conversion to index
% Call the gradCAM function
gradCamMap = gradCAM(trainedNetwork_1, MRI, classIndex);
For more information on "gridCAM", refer to this MATLAB documentation:
If the issue persists, could you please share the code file where you are encountering this error? So that I can investigate the issue.

Categories

Find more on Image Data Workflows in Help Center and File Exchange

Products


Release

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!