Filter löschen
Filter löschen

Why does my neural net data show up in R2021a but not in R2024a?

51 Ansichten (letzte 30 Tage)
Ifunanya Nwogbaga
Ifunanya Nwogbaga am 16 Jul. 2024 um 13:55
Kommentiert: Les Beckham am 18 Jul. 2024 um 16:17
I have a 1x1 struct variable that contains 6 fields. Each field is a 1x1 CompactClassificationNeuralNetwork, results from a neural network I use to train on images for image segmentation. When I open this struct in MATLAB R2021a, the struct contains all 6 fields. When I open it in 2024a, the struct contains 6 empty fields. The data doesn't appear. I have had trouble finding answers online. What might be the issue here?

Antworten (1)

Sahas
Sahas am 17 Jul. 2024 um 6:55
As per my understanding of the question, when the results from the neural network are analyzed, the 1x1 struct variable containing six fields of 1x1 “CompactClassificationNeuralNetwork” can be seen in MATLAB R2021a, but the fields appear empty in MATLAB R2024a.
Using the sample script provided below, I trained a neural network classifier using “fitcnet” function in MATLAB. Then I converted six models into compact models using the “compact” function and get the required struct using the “struct” function in MATLAB.
% Load sample data
load fisheriris;
% Prepare data
X = meas;
Y = species;
% Train a neural network classifier
Mdl1 = fitcnet(X, Y, 'LayerSizes', 10, 'Standardize', true);
Mdl2 = fitcnet(X, Y, 'LayerSizes', 20, 'Standardize', true);
Mdl3 = fitcnet(X, Y, 'LayerSizes', 30, 'Standardize', true);
Mdl4 = fitcnet(X, Y, 'LayerSizes', 40, 'Standardize', true);
Mdl5 = fitcnet(X, Y, 'LayerSizes', 50, 'Standardize', true);
Mdl6 = fitcnet(X, Y, 'LayerSizes', 60, 'Standardize', true);
% Convert to compact models
CompactMdl1 = compact(Mdl1);
CompactMdl2 = compact(Mdl2);
CompactMdl3 = compact(Mdl3);
CompactMdl4 = compact(Mdl4);
CompactMdl5 = compact(Mdl5);
CompactMdl6 = compact(Mdl6);
% Create a struct with these compact models
netStruct = struct('Model1', CompactMdl1, 'Model2', CompactMdl2, 'Model3', ...
CompactMdl3, 'Model4', CompactMdl4, 'Model5', CompactMdl5, 'Model6', CompactMdl6);
% Save the struct to a MAT-file
save('netStruct.mat', 'netStruct');
When executing the “netStruct” command in the command window, I was able to see the six 1x1 “CompactClassificationNeuralNetwork” fields in the struct in both MATLAB R2021a and R2024a.
If you have any questions, please share the results from the neural network used to train on images for image segmentation.
The following MATLAB documentation links might be helpful in learning more about the “CompactClassificationNeuralNetwork” and the “compact” functions.
  2 Kommentare
Ifunanya Nwogbaga
Ifunanya Nwogbaga am 18 Jul. 2024 um 14:50
Yes, your understanding of my question is correct. I have attached a .mat file with the struct in question. When you open it, a 1x1 struct should appear called "classifier_struct". This contains the six fields with a 1x1 CompactClassificationNeuralNetwork. This network was trained using fitcnet as well. Can you see nonempty fields in the struct on both MATLAB versions on your end?
Les Beckham
Les Beckham am 18 Jul. 2024 um 16:17
It loads and displays correctly in 2024a here in Answers.
whos -file fb_classifier_archive.mat
Name Size Bytes Class Attributes classifier_struct 1x1 46104 struct
load('fb_classifier_archive.mat')
classifier_struct
classifier_struct = struct with fields:
fb_model_PhC_C2DL_PSC01: [1x1 classreg.learning.classif.CompactClassificationNeuralNetwork] fb_model_Fluo_N2DL_HeLa01: [1x1 classreg.learning.classif.CompactClassificationNeuralNetwork] fb_model_Fluo_C2DL_MSC01: [1x1 classreg.learning.classif.CompactClassificationNeuralNetwork] fb_model_Fluo_C2DL_MSC02: [1x1 classreg.learning.classif.CompactClassificationNeuralNetwork] fb_model_Fluo_N2DL_HeLa02: [1x1 classreg.learning.classif.CompactClassificationNeuralNetwork] fb_model_PhC_C2DL_PSC02: [1x1 classreg.learning.classif.CompactClassificationNeuralNetwork]

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Deep Learning Toolbox finden Sie in Help Center und File Exchange

Produkte


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by