필터 지우기
필터 지우기

Datastore problems with deep learning. "FileExtensions Name-Value"

조회 수: 6 (최근 30일)
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.

채택된 답변

Steven Lord
Steven Lord 2023년 3월 9일
The imageDatastore object's documentation page states, in the description of the location input argument, that it "supports files that have an imformats format." Is the mat extension listed by imformats?
listOfFormats = imformats;
extensions = string([listOfFormats.ext]);
ismember("mat", extensions)
ans = logical
0
It is not. I'm not sure imageDatastore is the right tool for this job, or at least not with your data stored in MAT-files. If you really have image data, why not store the data in an image data file format? I happen to know that extensions has 25 elements, so to save space I'll reshape it into a 5-by-5 grid. Try saving your data in one of these formats using imwrite then create your datastore using those image files.
reshape(extensions, [5 5])
ans = 5×5 string array
"bmp" "hdf" "jpf" "pcx" "ras" "cur" "ico" "jpx" "pgm" "svs" "fts" "j2c" "jpg" "png" "tif" "fits" "j2k" "jpeg" "pnm" "tiff" "gif" "jp2" "pbm" "ppm" "xwd"

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by