Why won't trainNetwork recognise my layer object? - Error using trainNetwork (line 184) Layers argument must be an array of layers or a layer graph.

1 view (last 30 days)
I'm trying to produce my own basic CNN to solve a basic problem, however trainNetwork refuses to recognise any layer object or layerGraph object I create or copy-paste into my own script...,
please help!!!
%[xTrain, yTrain, xValidation, yValidation, augTrain, augValid] = trainingDataGetter(1);
load("augTrain.mat");
load("augValid.mat");
load("yTrain.mat");
load("yValid.mat");
layera = [...
imageInputLayer([24 24 3])
convolution3dLayer([1 1 3],8,'Padding',1)
fullyConnectedLayer(1)
regressionLayer
]
lgraph = layerGraph(layera);
miniBatchSize = 128;
validationFrequency = floor(numel(augTrain.Files)/miniBatchSize);
options = trainingOptions('sgdm', ...
'MiniBatchSize',miniBatchSize, ...
'MaxEpochs',30, ...
'InitialLearnRate',1e-3, ...
'LearnRateSchedule','piecewise', ...
'LearnRateDropFactor',0.1, ...
'LearnRateDropPeriod',20, ...
'Shuffle','every-epoch', ...
'ValidationData',{augValid,yValidation}, ...
'ValidationFrequency',validationFrequency, ...
'Plots','training-progress', ...
'Verbose',false);
net = trainNetwork(augTrain,yTrain,layera,options);

Answers (0)

Community Treasure Hunt

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

Start Hunting!