train the CNN for image classification by image in mat format

3 vues (au cours des 30 derniers jours)
Toqa Am
Toqa Am le 23 Déc 2019
Modifié(e) : Toqa Am le 27 Déc 2019
close all, clear all, clc;
output_folder=fullfile('datasets','New folder') ; %creat file path
categories={'pituitary','meningioma','glioma'};
imds=imageDatastore((fullfile(output_folder,categories)),'FileExtensions', '.mat','ReadFcn',@load,'LabelSource','foldernames');
[trainingset, testset]=splitEachLabel(imds, 0.8,0.2);
layers = [
...];
imageSize=layers(1).InputSize;
augmentedrainingset=augmentedImageDatastore (imageSize,...
trainingset,'colorPreprocessing','gray2rgb');
augmentedtestset=augmentedImageDatastore (imageSize,...
testset,'colorPreprocessing','gray2rgb');
options = trainingOptions('sgdm', ...
'InitialLearnRate',0.01, ...
'MaxEpochs',10, ...
'Shuffle','every-epoch', ...
'ValidationData',testset, ...
'ValidationFrequency',3, ...
'MiniBatchSize',32,...
'Verbose',false, ...
'Plots','training-progress');
net = trainNetwork(trainingset,layers,options);
Hi every one,
I try to trainng my CNN by image in mat format, but there is an error during that, which is
Error using trainNetwork (line 150)
Conversion to single from struct is not possible.
Error in classificationlayers (line 55)
net = trainNetwork(trainingset,layers,options);
Caused by:
Error using cast
Conversion to single from struct is not possible.
What can i do to solve this problem please??

Réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by