trainD=reshape(p_train,[144,30361]);%训练集输入
testD=reshape(p_test,[144,3005]);%测试集输入
targetD = t_train;%训练集输出
targetD_test = t_test;%测试集输出
%% CNN模型建立
layers = [
sequenceInputLayer(144,"Name","sequence")
averagePooling1dLayer(18,"Name","avgpool1d","Padding","same","Stride",18)
dropoutLayer(0.5,"Name","dropout")
fullyConnectedLayer(88,"Name","fc_1")
tanhLayer("Name","tanh_1")
fullyConnectedLayer(88,"Name","fc_2")
tanhLayer("Name","tanh_2")
fullyConnectedLayer(11,"Name","fc_3")
leakyReluLayer(0.01,"Name","leakyrelu")
regressionLayer("Name","regressionoutput")];
options = trainingOptions('adam',
'MaxEpochs',50,
'MiniBatchSize',256,
'InitialLearnRate',0.05,
'GradientThreshold',1,
'Verbose',false,
'ValidationFrequency',10,
'ExecutionEnvironment','auto',
'Plots','training-progress',
'ValidationData',{testD,targetD_test'});
% 训练
net = trainNetwork(trainD,targetD',layers,options);
错误使用 trainNetwork (第 184 行)
对于此运算,数组的大小不兼容。
原因:
对于此运算,数组的大小不兼容