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

1 回表示 (過去 30 日間)
Ifunanya Nwogbaga
Ifunanya Nwogbaga 2024 年 7 月 16 日
コメント済み: Les Beckham 2024 年 7 月 18 日
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?

回答 (1 件)

Sahas
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 件のコメント
Ifunanya Nwogbaga
Ifunanya Nwogbaga 2024 年 7 月 18 日
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 2024 年 7 月 18 日
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]

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDiscriminant Analysis についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by