Does gradCAM work on 3D image inputs?

6 次查看(过去 30 天)
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?

回答(1 个)

Hitesh
Hitesh 2024-10-21
编辑:Hitesh 2024-10-21
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.

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

产品


版本

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by