多输入多输出 | MATLAB实现BiTCN(双向时间卷积神经网络)多输入多输出预测
目录
- 多输入多输出 | MATLAB实现BiTCN(双向时间卷积神经网络)多输入多输出预测
- 预测效果
- 基本介绍
- 程序设计
- 参考资料
预测效果
基本介绍
Matlab实现BiTCN双向时间卷积神经网络多输入多输出预测
1.data为数据集,10个输入特征,3个输出变量。
2.main.m为主程序文件,其余为函数文件,无需运行,运行环境Matlab2021b及以上。
3.命令窗口输出MBE、MAE、MAPE、RMSE和R2,可在下载区获取数据和程序内容。
程序设计
- 完整源码和数据获取方式:私信博主回复MATLAB实现BiTCN(双向时间卷积神经网络)多输入多输出预测;
% 连接卷积层到残差块
lgraph = connectLayers(lgraph, outputName, "conv1_" + i);
% 创建 TCN反向支路flip网络结构
Fliplayers = [
FlipLayer("flip_" + i) % 反向翻转
convolution1dLayer(1, numFilters, Name = "convSkip_"+i); % 反向残差连接
convolution1dLayer(filterSize, numFilters, DilationFactor = dilationFactor, Padding = "causal", Name="conv2_" + i) % 一维卷积层
layerNormalizationLayer % 层归一化
spatialDropoutLayer(dropoutFactor) % 空间丢弃层
convolution1dLayer(filterSize, numFilters, DilationFactor = dilationFactor, Padding = "causal") % 一维卷积层
layerNormalizationLayer % 层归一化
reluLayer % 激活层
spatialDropoutLayer(dropoutFactor, Name="drop" + i) % 空间丢弃层
];
% 添加 flip 网络结构到网络
lgraph = addLayers(lgraph, Fliplayers);
% 连接 flip 卷积层到残差块
lgraph = connectLayers(lgraph, outputName, "flip_" + i);
lgraph = connectLayers(lgraph, "drop" + i, "add_" + i + "/in3");
lgraph = connectLayers(lgraph, "convSkip_"+i, "add_" + i + "/in4");
% 残差连接 -- 首层
if i == 1
% 建立残差卷积层
% Include convolution in first skip connection.
layer = convolution1dLayer(1,numFilters,Name="convSkip");
lgraph = addLayers(lgraph,layer);
lgraph = connectLayers(lgraph,outputName,"convSkip");
lgraph = connectLayers(lgraph,"convSkip","add_" + i + "/in2");
else
lgraph = connectLayers(lgraph,outputName,"add_" + i + "/in2");
end
% Update layer output name.
outputName = "add_" + i;
end
参考资料
[1] https://blog.csdn.net/kjm13182345320/article/details/128247182
[2] https://blog.csdn.net/kjm13182345320/article/details/126043107