多维时序 | Matlab实现BiTCN双向时间卷积神经网络多变量时间序列预测
目录
预测效果
基本介绍
1.Matlab实现BiTCN双向时间卷积神经网络多变量时间序列预测(完整源码和数据)
2.运行环境Matlab2023及以上,excel数据集,多列输入,单列输出,方便替换数据,考虑历史特征的影响;
3.多指标评价,评价指标包括:R2、MAE、MAPE、MSE等,代码质量极高。
程序设计
- 完整程序和数据获取方式资源处下载Matlab实现BiTCN双向时间卷积神经网络多变量时间序列预测。
clike
clc;clear;close all;format compact
tic
clc
clear all
% 创建TCN正向支路
layers = [
convolution1dLayer(filterSize, numFilters, DilationFactor = dilationFactor, Padding = "causal", Name="conv1_" + i) % 一维卷积层
layerNormalizationLayer % 层归一化
spatialDropoutLayer(dropoutFactor) % 空间丢弃层
convolution1dLayer(filterSize, numFilters, DilationFactor = dilationFactor, Padding = "causal") % 一维卷积层
layerNormalizationLayer % 层归一化
reluLayer % 激活层
spatialDropoutLayer(dropoutFactor) % 空间丢弃层
additionLayer(4, Name = "add_" + i)
];
% 添加残差块到网络
lgraph = addLayers(lgraph, layers);
% 连接卷积层到残差块
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
参考资料
[1] https://blog.csdn.net/kjm13182345320/category_11799242.html?spm=1001.2014.3001.5482
[2] https://blog.csdn.net/kjm13182345320/article/details/124571691