train the CNN for image classification by image in mat format
조회 수: 2 (최근 30일)
이전 댓글 표시
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??
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!