Error using dlarray/dlgradient : Value to differentiate is non-scalar. It must be a traced real dlarray scalar.
Show older comments
Hello, I want to train a Seq_to_one regression problem using a mae loss function found at "https://www.mathworks.com/help/deeplearning/ug/define-custom-regression-output-layer.html"
Input are :
X_train1 is 9x27 double array
Y_train2 is 9x3 double array
data_0.xlsx and mae loss function m file are attached
error occurred :
Error using trainNetwork
Error using 'backwardLoss' in Layer maeRegressionLayer. The function threw an error and could not be executed.
Caused by:
Error using dlarray/dlgradient
Value to differentiate is non-scalar. It must be a traced real dlarray scalar.
numChannels = 1;
numResponses = 3;
numHiddenUnits2 = 3;
X_train1 = xlsread('data_0.xlsx',1,'A2:AA10');
X_train2 = num2cell(X_train1,2);
Y_train2 = xlsread('data_0.xlsx',2,'A2:C10');
layers = [ ...
sequenceInputLayer(numChannels,Normalization="zscore")
gruLayer(numHiddenUnits2,OutputMode="last")
fullyConnectedLayer(3)
maeRegressionLayer('mae')];
opts = trainingOptions('adam',...
'MaxEpochs',3000000,...
'GradientThreshold',0.1,...
'InitialLearnRate',0.01,...
'MiniBatchSize',27,...
'ResetInputNormalization',false, ...
'VerboseFrequency',50, ...
'Plots','training-progress');
[net1,info] = trainNetwork(X_train2, Y_train2, layers, opts);
save net1;
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!