フィルターのクリア

Error using trainNetwork (line 184) Conversion to single from struct is not possible.

4 ビュー (過去 30 日間)
I am trying to implement the resnet50 on signal dataset.I have a database in which I have 10 folders(Each folder has 12 subfolders). Each file has dimensions 656x875x2 which is a .mat file. While running resnet on the above data I am facing below attached error. Can someone help me out?
location = 'D:\data-11\sir task\New folder\';
imds = imageDatastore(location, 'FileExtensions', '.mat', 'IncludeSubfolders',0, ...
'LabelSource','foldernames',...
'ReadFcn',@matReader);
[imdsTrain,imdsValidation] = splitEachLabel(imds,0.7, 'randomized');
net = lgraph_1;
inputSize = lgraph_1.Layers(1).InputSize;
[learnableLayer,classLayer] = findLayersToReplace(lgraph_1);
[learnableLayer,classLayer]
numClasses = numel(categories(imdsTrain.Labels));
if isa(learnableLayer,'nnet.cnn.layer.FullyConnectedLayer')
newLearnableLayer = fullyConnectedLayer(numClasses, ...
'Name','new_fc', ...
'WeightLearnRateFactor',10, ...
'BiasLearnRateFactor',10);
elseif isa(learnableLayer,'nnet.cnn.layer.Convolution2DLayer')
newLearnableLayer = convolution2dLayer(1,numClasses, ...
'Name','new_conv', ...
'WeightLearnRateFactor',10, ...
'BiasLearnRateFactor',10);
end
lgraph_1 = replaceLayer(lgraph_1,learnableLayer.Name,newLearnableLayer);
newClassLayer = classificationLayer('Name','new_classoutput');
lgraph_1 = replaceLayer(lgraph_1,classLayer.Name,newClassLayer);
miniBatchSize = 128;
valFrequency = floor(numel(imdsTrain.Files)/miniBatchSize);
checkpointPath = pwd;
options = trainingOptions('sgdm', ...
'MiniBatchSize',miniBatchSize, ...
'MaxEpochs',100, ...
'InitialLearnRate',1e-3, ...
'Shuffle','every-epoch', ...
'ValidationData',imdsValidation, ...
'ValidationFrequency',valFrequency, ...
'Verbose',false, ...
'Plots','training-progress', ...
'CheckpointPath',checkpointPath);
net = trainNetwork(imdsTrain,lgraph_1,options);
  9 件のコメント
Walter Roberson
Walter Roberson 2021 年 11 月 17 日
Please show your code for matReader()
john karli
john karli 2021 年 11 月 17 日
sure
function S = matReader(filename)
S = load(filename);
end

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

採用された回答

Walter Roberson
Walter Roberson 2021 年 11 月 17 日
When you load() a .mat file and assign the value to a variable, what you get back is a struct with one field for each variable in the file. You need to examine fieldnames(S) and decide which variable to extract from the struct. (The task is of course easier if all of the files contain the same variable name.)
  15 件のコメント
Walter Roberson
Walter Roberson 2021 年 11 月 22 日
bytes_required = (5000 * 0.7) * 656*875*2 * 8
bytes_required = 3.2144e+10
gigabytes_required = bytes_required / 2^30
gigabytes_required = 29.9364
You are almost certainly running out of memory.
john karli
john karli 2021 年 11 月 22 日
should i resize the 656x875x2 to 256x256x2?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParallel and Cloud についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by