Datastore problems with deep learning. "FileExtensions Name-Value"
显示 更早的评论
I keep getting an error about file formats (error message at the bottom).
I am writing a neural net that predicts risk for an area.
I have 6 greyscale maps layered on top of eachother.
I split them into 11x11 px images and stack them on top of eachother and name the files based on the middle pixel risk
I save the slices as .mat files.
After that I have [11 11 6] .mat files inside folders that act as labels.
I want to train on this data
Could someone suggest a way to fix this or a better file format that would work for this project?
files = ["C:\Users\filsz\Documents\MATLAB\test6\Data\very_low\*.mat",
... "C:\Users\filsz\Documents\MATLAB\test6\Data\low\*.mat", ...
"C:\Users\filsz\Documents\MATLAB\test6\Data\medium\*.mat", ...
"C:\Users\filsz\Documents\MATLAB\test6\Data\high\*.mat", ...
"C:\Users\filsz\Documents\MATLAB\test6\Data\very_high\*.mat"];
% load files into the ds
ds = fileDatastore(files,"ReadFcn",@load,"FileExtensions", ".mat");
ds = shuffle(ds);
%split into 2 partitions and get labels
dspTrain = partition(ds,2,1);
dspTest = partition(ds,2,2);
labelsTrain = folders2labels(dspTrain);
labelsTest = folders2labels(dspTest);
%create a table with [files, label] columns
filesTrain = dspTrain.Files;
filesTest = dspTest.Files;
Ttrain = table(filesTrain,labelsTrain);
Ttest = table(filesTrain,labelsTrain);
%convolutional NN layers and options
%this is just a first test so layers and options dont matter too much
layers = [ imageInputLayer([11 11 6])
convolution2dLayer([3 3],64,Stride=1)
reluLayer
maxPooling2dLayer([2 2],Stride=1)
convolution2dLayer([3 3],128,Stride=1)
reluLayer
maxPooling2dLayer([2 2],Stride=1)
convolution2dLayer([3 3],256,Stride=1)
reluLayer
maxPooling2dLayer([2 2],Stride=1)
flattenLayer
fullyConnectedLayer(200)
reluLayer
fullyConnectedLayer(100)
reluLayer
fullyConnectedLayer(5)
softmaxLayer
classificationLayer];
miniBatchSize = 2^18;
options = trainingOptions('adam', ...
'MiniBatchSize',miniBatchSize, ...
'Shuffle','every-epoch', ...
'Plots','training-progress', ...
'Verbose',false, MaxEpochs=1);
%training
net = trainNetwork(Ttrain,layers,options);
%(net = ... is my line 84 from the error message)
Thats the error I keep getting. (changing the filedatastore into imgdatastore with .mat extensions produces the same error)
Error using trainNetwork
Input folders or files contain non-standard file extensions.
Use FileExtensions Name-Value pair to include the non-standard file extensions.
Error in CNN (line 84)
net = trainNetwork(Ttrain,layers,options);
Caused by:
Error using imageDatastore
Input folders or files contain non-standard file extensions.
Use FileExtensions Name-Value pair to include the non-standard file extensions.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Deep Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!