Error using trainNetwork VALUESET must be the same class as DATA.

Hi. I'm trying to train a U-Net and the error that i'm getting is:
Error using trainNetwork
VALUESET must be the same class as DATA.
Caused by:
Error using ReadFcn @customReadFcn for file:
C:\Users\New User\OneDrive - ump.edu.my\Desktop\NewLabelOriginal\c0002s0002t01_lesionsmooth_115.mat
Error using categorical
VALUESET must be the same class as DATA.
Error in customReadFcn (line 7)
data = categorical(labels, [0, 1], {'Background', 'Tumor'});
I have attached the codes in this question.
Could someone lend a hand in troubleshooting this error?ubleshooting this error? Thank you for your time.

3 Comments

We need c0002s0002t01_lesionsmooth_115.mat for testing -- as outside observers we cannot assume that c0002s0002t01_lesionsmooth_115.mat has the same class() of data as c0001s0004t01_lesionsmooth_1.mat does.
Thank you for your time. I have attached this file in this reply.
Actually I have 38912 files in the folder. c0002s0002t01_lesionsmooth_115.mat is one of the files. But i cant upload all due to the limitation of the system.
May I know how can I do to fix this?
Thank you for your time.

Sign in to comment.

 Accepted Answer

load c0002s0002t01_lesionsmooth_115.mat
whos
Name Size Bytes Class Attributes ans 1x59 118 char cmdout 1x33 66 char imLesion 192x192 36972 categorical
The information in the file is already categorical, but your custom read function is trying to use
categorical(labels, [0, 1], {'Background', 'Tumor'})
which would be under the assumption that labels is numeric and that numeric 0 is to be associated with 'Background' and numeric 1 is to be associated with 'Tumor'
uc = unique(imLesion)
uc = categorical
0
double(uc)
ans = 1
Your existing imLesion array is categorical with category named 0 -- not category with value 0.
data = categorical(imLesion == '1', [0 1], {'Background', 'Tumor'});
data(1:3,1:3)
ans = 3×3 categorical array
Background Background Background Background Background Background Background Background Background

More Answers (0)

Categories

Asked:

on 16 May 2023

Commented:

on 16 May 2023

Community Treasure Hunt

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

Start Hunting!