分类预测 | MATLAB实现基于Attention-GRU的数据多特征分类预测(门控循环单元融合注意力机制分类预测,含混淆矩阵图、分类图)
效果一览
基本介绍
分类预测 | MATLAB实现基于Attention-GRU的数据多特征分类预测(门控循环单元融合注意力机制分类预测,含混淆矩阵图、分类图)文章来源:https://www.toymoban.com/news/detail-581339.html
程序设计
- 完整程序和数据私信博主回复:Attention-GRU的数据多特征分类预测
%% 获取GRU网络权重
grubias = params.gru.bias;
gruweight = params.gru.weights;
%% 同一个epoch中,不同Batch间的state是传递的,但不学习
h0 = state.gru.h0;
[GRU_Y, h0] = gru(p_train, h0, gruweight, grurecurrentWeights, grubias);
%% 注意力参数
Attentionweight = params.attention.weight; % 计算得分权重
Ht = GRU_Y(:, :, end); % 参考向量
num_time = size(GRU_Y, 3); % 时间尺度
%% 注意力得分
socre = dlarray;
for i = 1: num_time - 1
A = extractdata(squeeze(GRU_Y(:, :, i)));
A = repmat(A, [1, 1, num_hidden]);
end
%% 注意力得分
a = sigmoid(socre);
Vt = 0;
for i = 1: num_time - 1
Vt = Vt + a(i, :) .* GRU_Y(:, :, i);
end
%% 注意力机制
bias1 = params.attenout.bias1;
bias2 = params.attenout.bias2;
weight1 = params.attenout.weight1;
weight2 = params.attenout.weight2;
%% Attention输出
weight1 = params.attenout.weight1;
bias1 = params.attenout.bias1;
weight2 = params.attenout.weight2;
bias2 = params.attenout.bias2;
Hthat = fullyconnect(Vt,weight1,bias1) + fullyconnect(Ht,weight2,bias2);
%% 全连接层前置层(降维)
LastWeight = params.fullyconnect.weight1;
LastBias = params.fullyconnect.bias1 ;
FullyconnectInput = fullyconnect(Hthat,LastWeight,LastBias);
FullyconnectInput = relu(FullyconnectInput);
参考资料
[1] https://blog.csdn.net/kjm13182345320/article/details/128163536?spm=1001.2014.3001.5502
[2] https://blog.csdn.net/kjm13182345320/article/details/128151206?spm=1001.2014.3001.5502文章来源地址https://www.toymoban.com/news/detail-581339.html
到了这里,关于分类预测 | MATLAB实现基于Attention-GRU的数据多特征分类预测(门控循环单元融合注意力机制分类预测,含混淆矩阵图、分类图)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!