Why am I getting an Input data size error using "arrayDatastore" with "trainNetwork" (Deep Learning Toolbox)?
Show older comments
I am using the Deep Learning Toolbox in R2023a and wanted to train a very simple network with one 2-dimensional feature input and one regression output. The training data is provided in form of a combined "arrayDatastore" which has two columns. The first column has 2D-row vectors in each row, for the input features.
%% generate data
inData = randn(1000,3);
xTrain = arrayDatastore(inData(:,1:2));
yTrain = arrayDatastore(inData(:,3));
dataTrain = combine(xTrain,yTrain);
%% define network
layers = [
featureInputLayer(2,"Name","featureinput")
fullyConnectedLayer(20,"Name","fc_1")
reluLayer("Name","relu1")
fullyConnectedLayer(20,"Name","fc_2")
reluLayer("Name","relu2")
fullyConnectedLayer(20,"Name","fc_3")
reluLayer("Name","relu3")
fullyConnectedLayer(1,"Name","fc_4")
regressionLayer("Name","regressionoutput")];
lgraph = layerGraph(layers);
%% train network
options = trainingOptions('adam');
options.MaxEpochs = 1;
netTest = trainNetwork(dataTrain,layers,options);
However, I received the error message:
Error using trainNetwork
Input datastore returned more than one observation per row for network input 1.
Error in trainNetwork_ds_error (line 26)
netTest = trainNetwork(dataTrain,layers,options);
How can I create a compatible datastore from my simple input?
Accepted Answer
More Answers (0)
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!