Issue with LSTM training

1 回表示 (過去 30 日間)
Srikanth Kolachalama
Srikanth Kolachalama 2020 年 6 月 29 日
回答済み: Pranav Verma 2020 年 8 月 12 日
% Using the LSTM NN function.
clc; clear all; close all;
% Training the function.
inputTrain = xlsread('Vehicle_Data_MY19CadillacCT6.xlsx',1,'C38:L100');
ouputTrain = xlsread('Vehicle_Data_MY19CadillacCT6.xlsx',1,'M38:O100');
% Testing the results
inputTest = xlsread('Vehicle_Data_MY19CadillacCT6.xlsx',1,'C101:L110');
ouputTest = xlsread('Vehicle_Data_MY19CadillacCT6.xlsx',1,'M101:O110');
inputSize = 10;
outputSize = 3;
numHiddenUnits = 50;
layers = [ sequenceInputLayer(inputSize) lstmLayer(numHiddenUnits)
fullyConnectedLayer(outputSize) regressionLayer];
options = trainingOptions('adam', ...
'MaxEpochs',1000,...
'GradientThreshold',0.01, ...
'InitialLearnRate',0.0001);
net = trainNetwork(inputTrain,ouputTrain,layers,options);
outputPrediction = predict(net,inputTest);
Error using trainNetwork (line 170)
Error setting property 'ExternalLayers' of class 'nnet.internal.cnn.analyzer.NetworkAnalyzer':
Size of value must match specified dimensions M×1.
Error in PhD_Thesis_1 (line 24)
net = trainNetwork(inputTrain,ouputTrain,layers,options);
Caused by:
Error using nnet.internal.cnn.layer.util.inferParameters (line 7)
Error setting property 'ExternalLayers' of class 'nnet.internal.cnn.analyzer.NetworkAnalyzer':
Size of value must match specified dimensions M×1.

回答 (1 件)

Pranav Verma
Pranav Verma 2020 年 8 月 12 日
Hi Srikant,
From the provided code, it seems that you are creating an LSTM network for regression and while defining the layers, inputSize and outputSize does not match with the inputTrain and ouputTrain sizes. While defining the sequenceInputLayer size and fullyConnectedLayer size, use the sizes directly from the inputTrain and ouputTrain using the size function. Please refer to below documentation for size function:
Also, please refer to the following example for creating a regression LSTM network.
Thanks,
Pranav Verma

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by