Why does my neural net data show up in R2021a but not in R2024a?
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Sahas
2024년 7월 17일
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
Les Beckham
2024년 7월 18일
It loads and displays correctly in 2024a here in Answers.
whos -file fb_classifier_archive.mat
load('fb_classifier_archive.mat')
classifier_struct
참고 항목
카테고리
Help Center 및 File Exchange에서 Discriminant Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!