我尝试创建一个LSTM模型。我收到以下错误:
使用vertcat时出错,无法串联级联的数组的维数 一致的。源错误(第9行) sequenceInputLayer(33)
sequenceInputLayer
的输入内容和大小应该是什么?
Data = csvread('newData.csv');
num_timesteps = size(Data,1)
num_features = size(Data,2)
Data = normalize(Data);
numHiddenUnits = 200;
size(Data)
layers = [
sequenceInputLayer(33)
lstmLayer(numHiddenUnits,'OutputMode','sequence')
fullyConnectedLayer(50)
dropoutLayer(0.5)
fullyConnectedLayer(num_features),regressionLayer];
maxEpochs = 60;
miniBatchSize = 20;
options = trainingOptions('adam', ...
'MaxEpochs',maxEpochs, ...
'MiniBatchSize',miniBatchSize, ...
'InitialLearnRate',0.001, ...
'GradientThreshold',1, ...
'Shuffle','never', ...
'Plots','training-progress',...
'Verbose',0);
% net = trainNetwork(Data,Data,layers,options);
答案 0 :(得分:1)
问题不在sequenceInputLayer
中,问题出在创建layers
数组的方式中。
替换:
layers = [
sequenceInputLayer(33)
lstmLayer(numHiddenUnits,'OutputMode','sequence')
fullyConnectedLayer(50)
dropoutLayer(0.5)
fullyConnectedLayer(num_features),regressionLayer];
使用:
layers = [
sequenceInputLayer(33)
lstmLayer(numHiddenUnits,'OutputMode','sequence')
fullyConnectedLayer(50)
dropoutLayer(0.5)
fullyConnectedLayer(num_features),
regressionLayer];
说明::在数组声明中,在新行中添加元素(或以;
分隔)时,您正在创建列向量,而以,
分隔时,则是正在创建行向量。您以某种方式将它们混合在一起。