Why does my neural net data show up in R2021a but not in R2024a?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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?
0 Kommentare
Antworten (1)
Sahas
am 17 Jul. 2024
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
Les Beckham
am 18 Jul. 2024
It loads and displays correctly in 2024a here in Answers.
whos -file fb_classifier_archive.mat
load('fb_classifier_archive.mat')
classifier_struct
Siehe auch
Kategorien
Mehr zu Discriminant Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!