传统的基于特征提取与分类相结合的轴承智能诊断算法,对信号处理要求很高的专家经验,既费时又缺乏通用性。基于深度学习的智能轴承故障诊断方由于具有强大的特征提取能力,避免了繁琐复杂的特征提取工作,但是大多数研究都是在标准数据集下进行的,这意味着模型能够使用足量的数据进行训练,因此不会出现由于缺乏训练数据而导致深度模型诊断错误或过拟合问题。但是,在某些实际情况下,很难收集到足够的数据,例如当突然的故障发生时,在系统关闭前只能获取少量样本,来自这些故障的数据是稀缺的。出现这种情况的原因有几个:
(1)由于严重的后果不允许行轴承陷入故障状态;(2)大多数轴承故障发生缓慢,并遵循退化路径,使得轴承的故障退化可能需要数月甚至数年,这使得收集相关数据集变得困难;(3)机械设备的工况非常复杂,收集和标记足够各种工况下的训练样本是不现实的;(4)在实际应用中,故障类别和工作条件通常是不平衡的。以上数据不足或数据不平衡问题,故障样本都比较少,即为小样本问题。
为了解决小样本轴承故障诊断问题,现有的方法主要分为两个方面:
(1)数据增强;(2)选择特定算法。对于传统的数据增强方法而言,这些方法能增加数据量,但数据多样性没有发生质的改变,因此诊断效果有待提升;同时,这些方法可能引入噪声样本,也可能剔除重要的样本信息。生成对抗网络的出现弥补了上述方法的不足,用于轴承故障诊断获得了良好的结果,但目前它们都是基于一维信号的故障诊断方法,不能充分学习GAN及其变种图像生成的能力,生成样本质量不高和多样性差;同时,没有充分利用振动信号的时域和频域信息。对于现有的特定小样本轴承故障诊断算法而言,这些方法过分依赖丰富的人工经验,以及出现新的故障类型时,不能直接进行诊断,而需要收集足够的新的故障类型样本,输入模型重新训练再进行诊断。
鉴于此,提出一种基于注意力机制的小样本轴承故障诊断方法,运行环境为Python,采用Pytorch深度学习模块,采用模块如下:
import torch
import torch.nn as nn
import numpy as np
from datasave import train_loader, test_loader
from early_stopping import EarlyStopping
from label_smoothing import LSR
from oneD_Meta_ACON import MetaAconC
import time
from torchsummary import summary
from adabn import reset_bn, fix_bn
运行结果如下:
epoch: 70, Train Loss: 0.5524, Train Acc: 1.0000, Test Loss: 0.5565, Test Acc: 1.0000
EarlyStopping counter: 2 out of 10
epoch: 71, Train Loss: 0.5525, Train Acc: 1.0000, Test Loss: 0.5552, Test Acc: 1.0000
Validation loss decreased (0.555630 --> 0.555175). Saving model ...
epoch: 72, Train Loss: 0.5519, Train Acc: 1.0000, Test Loss: 0.5584, Test Acc: 1.0000
EarlyStopping counter: 1 out of 10
epoch: 73, Train Loss: 0.5517, Train Acc: 1.0000, Test Loss: 0.5550, Test Acc: 1.0000
Validation loss decreased (0.555175 --> 0.555048). Saving model ...
epoch: 74, Train Loss: 0.5514, Train Acc: 1.0000, Test Loss: 0.5544, Test Acc: 1.0000
Validation loss decreased (0.555048 --> 0.554380). Saving model ...
epoch: 75, Train Loss: 0.5516, Train Acc: 1.0000, Test Loss: 0.5560, Test Acc: 1.0000
EarlyStopping counter: 1 out of 10
epoch: 76, Train Loss: 0.5508, Train Acc: 1.0000, Test Loss: 0.5542, Test Acc: 1.0000
Validation loss decreased (0.554380 --> 0.554152). Saving model ...
epoch: 77, Train Loss: 0.5507, Train Acc: 1.0000, Test Loss: 0.5546, Test Acc: 1.0000
EarlyStopping counter: 1 out of 10
epoch: 78, Train Loss: 0.5506, Train Acc: 1.0000, Test Loss: 0.5546, Test Acc: 1.0000
EarlyStopping counter: 2 out of 10
epoch: 79, Train Loss: 0.5505, Train Acc: 1.0000, Test Loss: 0.5541, Test Acc: 1.0000
Validation loss decreased (0.554152 --> 0.554113). Saving model ...
epoch: 80, Train Loss: 0.5503, Train Acc: 1.0000, Test Loss: 0.5536, Test Acc: 1.0000
Validation loss decreased (0.554113 --> 0.553636). Saving model ...
epoch: 81, Train Loss: 0.5501, Train Acc: 1.0000, Test Loss: 0.5534, Test Acc: 1.0000
Validation loss decreased (0.553636 --> 0.553374). Saving model ...
epoch: 82, Train Loss: 0.5501, Train Acc: 1.0000, Test Loss: 0.5536, Test Acc: 1.0000
EarlyStopping counter: 1 out of 10
epoch: 83, Train Loss: 0.5500, Train Acc: 1.0000, Test Loss: 0.5542, Test Acc: 1.0000
EarlyStopping counter: 2 out of 10
epoch: 84, Train Loss: 0.5507, Train Acc: 1.0000, Test Loss: 0.5554, Test Acc: 1.0000
EarlyStopping counter: 3 out of 10
epoch: 85, Train Loss: 0.5499, Train Acc: 1.0000, Test Loss: 0.5531, Test Acc: 1.0000
Validation loss decreased (0.553374 --> 0.553104). Saving model ...
epoch: 86, Train Loss: 0.5499, Train Acc: 1.0000, Test Loss: 0.5527, Test Acc: 1.0000
Validation loss decreased (0.553104 --> 0.552698). Saving model ...
epoch: 87, Train Loss: 0.5498, Train Acc: 1.0000, Test Loss: 0.5531, Test Acc: 1.0000
EarlyStopping counter: 1 out of 10
epoch: 88, Train Loss: 0.5493, Train Acc: 1.0000, Test Loss: 0.5532, Test Acc: 1.0000
EarlyStopping counter: 2 out of 10
epoch: 89, Train Loss: 0.5495, Train Acc: 1.0000, Test Loss: 0.5523, Test Acc: 1.0000
Validation loss decreased (0.552698 --> 0.552310). Saving model ...
epoch: 90, Train Loss: 0.5494, Train Acc: 1.0000, Test Loss: 0.5531, Test Acc: 1.0000
EarlyStopping counter: 1 out of 10
epoch: 91, Train Loss: 0.5492, Train Acc: 1.0000, Test Loss: 0.5538, Test Acc: 1.0000
EarlyStopping counter: 2 out of 10
epoch: 92, Train Loss: 0.5492, Train Acc: 1.0000, Test Loss: 0.5529, Test Acc: 1.0000
EarlyStopping counter: 3 out of 10
epoch: 93, Train Loss: 0.5491, Train Acc: 1.0000, Test Loss: 0.5526, Test Acc: 1.0000
EarlyStopping counter: 4 out of 10
epoch: 94, Train Loss: 0.5489, Train Acc: 1.0000, Test Loss: 0.5529, Test Acc: 1.0000
EarlyStopping counter: 5 out of 10
epoch: 95, Train Loss: 0.5487, Train Acc: 1.0000, Test Loss: 0.5528, Test Acc: 1.0000
EarlyStopping counter: 6 out of 10
epoch: 96, Train Loss: 0.5484, Train Acc: 1.0000, Test Loss: 0.5528, Test Acc: 1.0000
EarlyStopping counter: 7 out of 10
epoch: 97, Train Loss: 0.5485, Train Acc: 1.0000, Test Loss: 0.5517, Test Acc: 1.0000
Validation loss decreased (0.552310 --> 0.551687). Saving model ...
epoch: 98, Train Loss: 0.5484, Train Acc: 1.0000, Test Loss: 0.5514, Test Acc: 1.0000
Validation loss decreased (0.551687 --> 0.551363). Saving model ...
epoch: 99, Train Loss: 0.5484, Train Acc: 1.0000, Test Loss: 0.5515, Test Acc: 1.0000
EarlyStopping counter: 1 out of 10
epoch: 100, Train Loss: 0.5483, Train Acc: 1.0000, Test Loss: 0.5524, Test Acc: 1.0000
EarlyStopping counter: 2 out of 10
epoch: 101, Train Loss: 0.5487, Train Acc: 1.0000, Test Loss: 0.5549, Test Acc: 1.0000
EarlyStopping counter: 3 out of 10
epoch: 102, Train Loss: 0.5507, Train Acc: 1.0000, Test Loss: 0.5597, Test Acc: 1.0000
EarlyStopping counter: 4 out of 10
epoch: 103, Train Loss: 0.5495, Train Acc: 1.0000, Test Loss: 0.5540, Test Acc: 1.0000
EarlyStopping counter: 5 out of 10
epoch: 104, Train Loss: 0.5586, Train Acc: 0.9972, Test Loss: 0.5980, Test Acc: 1.0000
EarlyStopping counter: 6 out of 10
epoch: 105, Train Loss: 0.5563, Train Acc: 1.0000, Test Loss: 0.6087, Test Acc: 0.9900
EarlyStopping counter: 7 out of 10
epoch: 106, Train Loss: 0.5541, Train Acc: 1.0000, Test Loss: 0.6079, Test Acc: 1.0000
EarlyStopping counter: 8 out of 10
epoch: 107, Train Loss: 0.5515, Train Acc: 1.0000, Test Loss: 0.5953, Test Acc: 0.9967
EarlyStopping counter: 9 out of 10
epoch: 108, Train Loss: 0.5503, Train Acc: 1.0000, Test Loss: 0.5740, Test Acc: 0.9967
EarlyStopping counter: 10 out of 10
Early stopping
time:1384.973 s
完整代码:
Python环境下基于注意力机制的小样本轴承故障诊断-今日头条 (toutiao.com)
擅长领域:现代信号处理,机器学习,深度学习,数字孪生,时间序列分析,设备缺陷检测、设备异常检测、设备智能故障诊断与健康管理PHM等。
标签:Acc,轴承,Loss,Python,1.0000,故障诊断,epoch,Train,Test From: https://blog.csdn.net/weixin_39402231/article/details/136805094