多输入多输出 | MATLAB实现GRU门控循环单元多输入多输出
目录
- 多输入多输出 | MATLAB实现GRU门控循环单元多输入多输出
- 预测效果
- 基本介绍
- 程序设计
- 往期精彩
- 参考资料
预测效果
基本介绍
MATLAB实现GRU门控循环单元多输入多输出,数据为多输入多输出预测数据,输入10个特征,输出3个变量,程序乱码是由于版本不一致导致,可以用记事本打开复制到你的文件,运行环境MATLAB2020b及以上。命令窗口输出MAE和R2,可在下载区获取数据和程序内容。
程序设计
- 完整程序和数据下载方式(资源处直接下载):MATLAB实现GRU门控循环单元多输入多输出
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
layers = [ ...
sequenceInputLayer(numFeatures)
fullyConnectedLayer(numResponses)
regressionLayer];
options = trainingOptions('adam', ...
'MaxEpochs',250, ...
'GradientThreshold',1, ...
'InitialLearnRate',0.005, ...
'LearnRateSchedule','piecewise', ...
'LearnRateDropPeriod',125, ...
'LearnRateDropFactor',0.2, ...
'ExecutionEnvironment','cpu', ...
'Verbose',0, ...
'Plots','training-progress');
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
net = trainNetwork(XTrain,YTrain,layers,options);
dataTestStandardized = (dataTest - mu) / sig;
XTest = dataTestStandardized(1:end-1);
net = predictAndUpdateState(net,XTrain);
[net,YPred] = predictAndUpdateState(net,YTrain(end));
numTimeStepsTest = numel(XTest);
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------