Author Login Chief Editor Login Reviewer Login Editor Login Remote Office

Computer Engineering

   

Enhanced Blockchain-Based Federated Learning with Attention Mechanisms

  

  • Published:2026-12-03

基于注意力机制的区块链联邦学习改进策略研究

Abstract: To address the difficulty faced by existing blockchain-based federated learning schemes in balancing model accuracy and robustness in the presence of malicious nodes, this paper proposes an improved blockchain-based federated learning strategy based on multi-head attention. On the client side, a dual-branch model comprising parallel convolutional neural network (CNN) and multi-head self-attention branches is constructed to extract local spatial features and non-local dependencies, respectively, thereby compensating for the limited ability of conventional CNNs to model fine-grained feature relationships. On this basis, a dynamic branch-weighted fusion mechanism with a learnable temperature parameter is designed to generate adaptive weights from the joint features of the two branches and dynamically combine their classification outputs. When the feature representation of one branch is perturbed, the mechanism adjusts its contribution to the final prediction, thereby mitigating the influence of perturbed features on local training. During global aggregation, federated averaging is first performed on the client updates to obtain preliminary reference parameters. Pseudo-reliability labels are then generated according to the directional consistency between each client parameter and the reference parameters, and a client-parameter scoring network is trained online. The preliminary reference parameters are used as the query, while the client parameters serve as the keys and values. Multi-head attention is employed to measure the association between each client update and the collective reference direction. The reliability scores are incorporated as prior information and combined with the attention-based association weights to determine the final aggregation coefficients, thereby adaptively down-weighting abnormal or low-quality updates. The proposed strategy is further integrated with blockchain-based Proof-of-Stake (PoS) consensus and blacklist mechanisms to establish a hierarchical defense framework. Experiments are conducted on the MNIST, Fashion-MNIST, FEMNIST, and CIFAR-10 datasets under label-flipping, bit-flipping, and scaling attacks. The results show that, with 15% malicious nodes, MBAFL achieves the highest accuracy in all 12 experimental settings, outperforming the best baseline in each setting by 0.02–0.11. When the proportion of malicious nodes increases to 25%, the model still maintains a relatively stable convergence trend. Under the 25% malicious-node setting, MBAFL achieves recall rates of 0.87 and 0.67 on MNIST and CIFAR-10, respectively, exceeding the best-performing comparison method by 0.11 and 0.09. Furthermore, ablation experiments verify the effectiveness of the core modules and the synergy among them. Overall, the proposed strategy effectively balances model accuracy and convergence stability in blockchain-based federated learning under malicious-node environments.

摘要: 摘 要: 针对现有区块链联邦学习方案在恶意节点环境下难以兼顾模型精度与鲁棒性的问题,提出一种基于多头注意力的区块链联邦学习改进策略。客户端构建CNN与多头自注意力并行的双分支模型,分别提取局部空间特征和非局部关联信息,以弥补传统CNN对细粒度关联建模能力不足的问题。在此基础上,设计带可学习温度参数的动态分支加权融合机制,根据双分支联合特征生成自适应权重,并对两个分支的分类输出进行动态加权。当某一分支的特征表示受到扰动时,该机制能够调整其在最终预测中的贡献比例,从而减弱受扰动特征对本地训练的影响。全局聚合阶段,首先对客户端更新执行联邦平均,得到初步参考参数;随后根据各客户端参数与参考参数之间的方向一致性生成伪可靠性标签,在线训练客户端参数评分网络。以初步参考参数作为Query、客户端参数作为Key和Value,通过多头注意力计算客户端更新与群体参考方向之间的关联程度,并将可靠性评分作为先验信息,与注意力关联权重联合确定最终聚合系数,实现异常或低质量更新的自适应降权。该策略进一步与区块链权益证明共识及黑名单机制结合,形成层级化防御体系。实验选取MNIST、Fashion-MNIST、FEMNIST和CIFAR-10数据集,并设置标签翻转、比特翻转和缩放攻击进行验证。结果表明,在15%恶意节点条件下,MBAFL在12组准确率实验中均取得最高值,相较各组最优基线提高0.02~0.11;当恶意节点比例增至25%时,模型仍保持较稳定的收敛趋势。在25%恶意节点条件下,MBAFL在MNIST和CIFAR-10上的召回率分别达到0.87和0.67,较最优对比方案分别提高0.11和0.09。在此基础上,消融实验进一步验证了各核心模块的有效性与协同机制,该策略能够有效兼顾区块链联邦学习在恶意环境下的模型精度与收敛稳定性。