当前位置:   article > 正文

Pytorch环境下基于Transformer的滚动轴承故障诊断_轴承数据故障诊断pytorch

轴承数据故障诊断pytorch

关于python的集成环境,我一般Anaconda 和 winpython 都用,windows下主要用WinpythonIDE为spyder(类MATLAB界面)。

winpython脱胎于pythonxy,面向科学计算兼顾数据分析与挖掘;Anaconda主要面向数据分析与挖掘方面,在大数据处理方面有自己特色的一些包;winpython强调便携性,被做成绿色软件,不写入注册表,安装其实就是解压到某个文件夹,移动文件夹甚至放到U盘里在其他电脑上也能用;Anaconda则算是传统的软件模式。winpython是由个人维护;Anaconda由数据分析服务公司维护,意味着Winpython在很多方面都从简,而Anaconda会提供一些人性化设置。Winpython 只能在windows上用,Anaconda则有linux的版本。

抛开软件包的差异,我个人也推荐初学者用winpython,正因为其简单,问题也少点,由于便携性的特点系统坏了,重装后也能直接用。

请直接安装、使用winPython:WinPython download因为很多模块以及集成的模块

可以选择版本,不一定要用最新版本,否则可能出现不兼容问题。

下载、解压后如下

打开spyder就可以用了,里面自带pytorch.

开始步入正题,进行基于Transformer的滚动轴承故障诊断,Transformer模型就不多说了,很多论文都有介绍。

用的数据集是简单的西储大学数据集

 为了便于处理,转换为csv文件类型

 

加载相关模块

  1. import torch
  2. import torch.nn as nn
  3. import torch.optim as optim
  4. from model import DSCTransformer
  5. from tqdm import tqdm
  6. from data_set import MyDataset
  7. from torch.utils.data import DataLoader

定于训练函数

  1. def train(epochs=100):
  2. #定义参数
  3. N = 4 #编码器个数
  4. input_dim = 1024
  5. seq_len = 16 #句子长度
  6. d_model = 64 #词嵌入维度
  7. d_ff = 256 #全连接层维度
  8. head = 4 #注意力头数
  9. dropout = 0.1
  10. lr = 5E-5 #学习率
  11. batch_size = 32
  12. #加载数据
  13. train_path = r'data\train\train.csv'
  14. val_path = r'data\val\val.csv'
  15. train_dataset = MyDataset(train_path, 'fd')
  16. val_dataset = MyDataset(val_path, 'fd')
  17. train_loader = DataLoader(dataset=train_dataset, batch_size=batch_size, shuffle=True, drop_last=True)
  18. val_loader = DataLoader(dataset=val_dataset, batch_size=batch_size, shuffle=True, drop_last=True)
  19. #定义模型
  20. model = DSCTransformer(input_dim=input_dim, num_classes=10, dim=d_model, depth=N,
  21. heads=head, mlp_dim=d_ff, dim_head=d_model, emb_dropout=dropout, dropout=dropout)
  22. criterion = nn.CrossEntropyLoss()
  23. params = [p for p in model.parameters() if p.requires_grad]
  24. optimizer = optim.Adam(params, lr=lr)
  25. device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
  26. print("using {} device.".format(device))
  27. model.to(device)
  28. #训练
  29. for epoch in range(epochs):
  30. #train
  31. train_loss = []
  32. train_acc = []
  33. model.train()
  34. train_bar = tqdm(train_loader)
  35. for datas, labels in train_bar:
  36. optimizer.zero_grad()
  37. outputs = model(datas.float().to(device))
  38. loss = criterion(outputs, labels.type(torch.LongTensor).to(device))
  39. loss.backward()
  40. optimizer.step()
  41. # torch.argmax(dim=-1), 求每一行最大的列序号
  42. acc = (outputs.argmax(dim=-1) == labels.to(device)).float().mean()
  43. # Record the loss and accuracy
  44. train_loss.append(loss.item())
  45. train_acc.append(acc)
  46. train_bar.desc = "train epoch[{}/{}] loss:{:.3f}".format(epoch + 1, epochs, loss.item())
  47. #val
  48. model.eval()
  49. valid_loss = []
  50. valid_acc = []
  51. val_bar = tqdm(val_loader)
  52. for datas, labels in val_bar:
  53. with torch.no_grad():
  54. outputs = model(datas.float().to(device))
  55. loss = criterion(outputs, labels.type(torch.LongTensor).to(device))
  56. acc = (outputs.argmax(dim=-1) == labels.to(device)).float().mean()
  57. # Record the loss and accuracy
  58. valid_loss.append(loss.item())
  59. valid_acc.append(acc)
  60. val_bar.desc = "valid epoch[{}/{}]".format(epoch + 1, epochs)
  61. print(f"[{epoch + 1:02d}/{epochs:02d}] train loss = "
  62. f"{sum(train_loss) / len(train_loss):.5f}, train acc = {sum(train_acc) / len(train_acc):.5f}", end=" ")
  63. print(f"valid loss = {sum(valid_loss) / len(valid_loss):.5f}, valid acc = {sum(valid_acc) / len(valid_acc):.5f}")

关于Transformer模型,部分截图如下

训练

  1. if __name__ == '__main__':
  2. train()

结果如下

using cpu device.

train epoch[1/100] loss:2.256: 100%|██████████| 37/37 [00:03<00:00, 12.25it/s]

valid epoch[1/100]: 100%|██████████| 12/12 [00:00<00:00, 22.20it/s]

[01/100] train loss = 2.34002, train acc = 0.15456 valid loss = 2.20410, valid acc = 0.22917

train epoch[2/100] loss:2.124: 100%|██████████| 37/37 [00:02<00:00, 17.70it/s]

valid epoch[2/100]: 100%|██████████| 12/12 [00:00<00:00, 72.03it/s]

[02/100] train loss = 2.17655, train acc = 0.26943 valid loss = 2.02880, valid acc = 0.36198

train epoch[3/100] loss:2.024: 100%|██████████| 37/37 [00:01<00:00, 19.73it/s]

valid epoch[3/100]: 100%|██████████| 12/12 [00:00<00:00, 70.79it/s]

[03/100] train loss = 1.97657, train acc = 0.37838 valid loss = 1.77005, valid acc = 0.42448

train epoch[4/100] loss:1.533: 100%|██████████| 37/37 [00:01<00:00, 21.36it/s]

valid epoch[4/100]: 100%|██████████| 12/12 [00:00<00:00, 72.92it/s]

[04/100] train loss = 1.72868, train acc = 0.44679 valid loss = 1.45628, valid acc = 0.57031

train epoch[5/100] loss:1.324: 100%|██████████| 37/37 [00:01<00:00, 21.43it/s]

valid epoch[5/100]: 100%|██████████| 12/12 [00:00<00:00, 73.37it/s]

[05/100] train loss = 1.43806, train acc = 0.57855 valid loss = 1.14773, valid acc = 0.70833

train epoch[6/100] loss:0.977: 100%|██████████| 37/37 [00:01<00:00, 21.53it/s]

valid epoch[6/100]: 100%|██████████| 12/12 [00:00<00:00, 81.85it/s]

[06/100] train loss = 1.20136, train acc = 0.68919 valid loss = 0.93165, valid acc = 0.71875

train epoch[7/100] loss:0.918: 100%|██████████| 37/37 [00:01<00:00, 20.55it/s]

valid epoch[7/100]: 100%|██████████| 12/12 [00:00<00:00, 76.62it/s]

[07/100] train loss = 1.01878, train acc = 0.76014 valid loss = 0.78236, valid acc = 0.79167

train epoch[8/100] loss:0.837: 100%|██████████| 37/37 [00:01<00:00, 21.41it/s]

valid epoch[8/100]: 100%|██████████| 12/12 [00:00<00:00, 81.85it/s]

[08/100] train loss = 0.88433, train acc = 0.80743 valid loss = 0.67526, valid acc = 0.85156

train epoch[9/100] loss:0.866: 100%|██████████| 37/37 [00:01<00:00, 18.51it/s]

valid epoch[9/100]: 100%|██████████| 12/12 [00:00<00:00, 75.20it/s]

[09/100] train loss = 0.77536, train acc = 0.85304 valid loss = 0.61958, valid acc = 0.84375

train epoch[10/100] loss:0.650: 100%|██████████| 37/37 [00:01<00:00, 21.53it/s]

valid epoch[10/100]: 100%|██████████| 12/12 [00:00<00:00, 83.54it/s]

[10/100] train loss = 0.68927, train acc = 0.87838 valid loss = 0.53588, valid acc = 0.88802

train epoch[11/100] loss:0.554: 100%|██████████| 37/37 [00:01<00:00, 21.03it/s]

valid epoch[11/100]: 100%|██████████| 12/12 [00:00<00:00, 75.18it/s]

[11/100] train loss = 0.63142, train acc = 0.89780 valid loss = 0.50332, valid acc = 0.89583

train epoch[12/100] loss:0.491: 100%|██████████| 37/37 [00:01<00:00, 21.66it/s]

valid epoch[12/100]: 100%|██████████| 12/12 [00:00<00:00, 74.73it/s]

[12/100] train loss = 0.56722, train acc = 0.91470 valid loss = 0.47348, valid acc = 0.90885

train epoch[13/100] loss:0.474: 100%|██████████| 37/37 [00:01<00:00, 21.36it/s]

valid epoch[13/100]: 100%|██████████| 12/12 [00:00<00:00, 74.71it/s]

[13/100] train loss = 0.51700, train acc = 0.93328 valid loss = 0.42631, valid acc = 0.91667

train epoch[14/100] loss:0.532: 100%|██████████| 37/37 [00:01<00:00, 21.64it/s]

valid epoch[14/100]: 100%|██████████| 12/12 [00:00<00:00, 74.27it/s]

[14/100] train loss = 0.48976, train acc = 0.93581 valid loss = 0.41196, valid acc = 0.93490

train epoch[15/100] loss:0.418: 100%|██████████| 37/37 [00:01<00:00, 21.76it/s]

valid epoch[15/100]: 100%|██████████| 12/12 [00:00<00:00, 84.14it/s]

[15/100] train loss = 0.44979, train acc = 0.94003 valid loss = 0.38338, valid acc = 0.93229

train epoch[16/100] loss:0.365: 100%|██████████| 37/37 [00:01<00:00, 21.68it/s]

valid epoch[16/100]: 100%|██████████| 12/12 [00:00<00:00, 74.27it/s]

[16/100] train loss = 0.41998, train acc = 0.95439 valid loss = 0.34409, valid acc = 0.93750

train epoch[17/100] loss:0.374: 100%|██████████| 37/37 [00:01<00:00, 21.87it/s]

valid epoch[17/100]: 100%|██████████| 12/12 [00:00<00:00, 78.64it/s]

[17/100] train loss = 0.38335, train acc = 0.95777 valid loss = 0.33143, valid acc = 0.94531

train epoch[18/100] loss:0.304: 100%|██████████| 37/37 [00:01<00:00, 21.56it/s]

valid epoch[18/100]: 100%|██████████| 12/12 [00:00<00:00, 72.92it/s]

[18/100] train loss = 0.36607, train acc = 0.95777 valid loss = 0.29637, valid acc = 0.95312

train epoch[19/100] loss:0.273: 100%|██████████| 37/37 [00:01<00:00, 21.38it/s]

valid epoch[19/100]: 100%|██████████| 12/12 [00:00<00:00, 72.48it/s]

[19/100] train loss = 0.33524, train acc = 0.96791 valid loss = 0.28047, valid acc = 0.95052

train epoch[20/100] loss:0.265: 100%|██████████| 37/37 [00:01<00:00, 21.98it/s]

valid epoch[20/100]: 100%|██████████| 12/12 [00:00<00:00, 77.63it/s]

[20/100] train loss = 0.31162, train acc = 0.96875 valid loss = 0.26248, valid acc = 0.96094

train epoch[21/100] loss:0.198: 100%|██████████| 37/37 [00:01<00:00, 21.58it/s]

valid epoch[21/100]: 100%|██████████| 12/12 [00:00<00:00, 70.78it/s]

[21/100] train loss = 0.29139, train acc = 0.97382 valid loss = 0.25048, valid acc = 0.95833

train epoch[22/100] loss:0.260: 100%|██████████| 37/37 [00:01<00:00, 21.07it/s]

valid epoch[22/100]: 100%|██████████| 12/12 [00:00<00:00, 81.30it/s]

[22/100] train loss = 0.27686, train acc = 0.97889 valid loss = 0.23296, valid acc = 0.95833

train epoch[23/100] loss:0.210: 100%|██████████| 37/37 [00:01<00:00, 21.26it/s]

valid epoch[23/100]: 100%|██████████| 12/12 [00:00<00:00, 73.37it/s]

[23/100] train loss = 0.24999, train acc = 0.98480 valid loss = 0.22225, valid acc = 0.96354

train epoch[24/100] loss:0.268: 100%|██████████| 37/37 [00:01<00:00, 21.44it/s]

valid epoch[24/100]: 100%|██████████| 12/12 [00:00<00:00, 72.48it/s]

[24/100] train loss = 0.23558, train acc = 0.98057 valid loss = 0.20795, valid acc = 0.96354

train epoch[25/100] loss:0.168: 100%|██████████| 37/37 [00:01<00:00, 21.56it/s]

valid epoch[25/100]: 100%|██████████| 12/12 [00:00<00:00, 69.95it/s]

[25/100] train loss = 0.21769, train acc = 0.98480 valid loss = 0.18703, valid acc = 0.96615

train epoch[26/100] loss:0.274: 100%|██████████| 37/37 [00:01<00:00, 21.75it/s]

valid epoch[26/100]: 100%|██████████| 12/12 [00:00<00:00, 73.82it/s]

[26/100] train loss = 0.20820, train acc = 0.98057 valid loss = 0.17861, valid acc = 0.97135

train epoch[27/100] loss:0.185: 100%|██████████| 37/37 [00:01<00:00, 21.49it/s]

valid epoch[27/100]: 100%|██████████| 12/12 [00:00<00:00, 76.15it/s]

[27/100] train loss = 0.19181, train acc = 0.99071 valid loss = 0.16663, valid acc = 0.97396

train epoch[28/100] loss:0.181: 100%|██████████| 37/37 [00:01<00:00, 21.00it/s]

valid epoch[28/100]: 100%|██████████| 12/12 [00:00<00:00, 67.22it/s]

[28/100] train loss = 0.17669, train acc = 0.99324 valid loss = 0.16026, valid acc = 0.97135

train epoch[29/100] loss:0.171: 100%|██████████| 37/37 [00:01<00:00, 19.92it/s]

valid epoch[29/100]: 100%|██████████| 12/12 [00:00<00:00, 71.62it/s]

[29/100] train loss = 0.16942, train acc = 0.98818 valid loss = 0.14299, valid acc = 0.98698

train epoch[30/100] loss:0.113: 100%|██████████| 37/37 [00:01<00:00, 21.47it/s]

valid epoch[30/100]: 100%|██████████| 12/12 [00:00<00:00, 72.92it/s]

[30/100] train loss = 0.15469, train acc = 0.99240 valid loss = 0.13816, valid acc = 0.98177

train epoch[31/100] loss:0.142: 100%|██████████| 37/37 [00:01<00:00, 20.68it/s]

valid epoch[31/100]: 100%|██████████| 12/12 [00:00<00:00, 72.92it/s]

[31/100] train loss = 0.14401, train acc = 0.99071 valid loss = 0.13443, valid acc = 0.97917

train epoch[32/100] loss:0.109: 100%|██████████| 37/37 [00:01<00:00, 21.16it/s]

valid epoch[32/100]: 100%|██████████| 12/12 [00:00<00:00, 70.78it/s]

[32/100] train loss = 0.14164, train acc = 0.99071 valid loss = 0.12356, valid acc = 0.98698

train epoch[33/100] loss:0.097: 100%|██████████| 37/37 [00:01<00:00, 20.21it/s]

valid epoch[33/100]: 100%|██████████| 12/12 [00:00<00:00, 74.27it/s]

[33/100] train loss = 0.13008, train acc = 0.99240 valid loss = 0.11986, valid acc = 0.98177

train epoch[34/100] loss:0.154: 100%|██████████| 37/37 [00:01<00:00, 21.04it/s]

valid epoch[34/100]: 100%|██████████| 12/12 [00:00<00:00, 74.27it/s]

[34/100] train loss = 0.11819, train acc = 0.99155 valid loss = 0.11186, valid acc = 0.98958

train epoch[35/100] loss:0.113: 100%|██████████| 37/37 [00:01<00:00, 21.00it/s]

valid epoch[35/100]: 100%|██████████| 12/12 [00:00<00:00, 71.62it/s]

[35/100] train loss = 0.11408, train acc = 0.99409 valid loss = 0.10467, valid acc = 0.99219

train epoch[36/100] loss:0.081: 100%|██████████| 37/37 [00:01<00:00, 21.57it/s]

valid epoch[36/100]: 100%|██████████| 12/12 [00:00<00:00, 71.18it/s]

[36/100] train loss = 0.10629, train acc = 0.99493 valid loss = 0.10322, valid acc = 0.98698

train epoch[37/100] loss:0.068: 100%|██████████| 37/37 [00:01<00:00, 21.14it/s]

valid epoch[37/100]: 100%|██████████| 12/12 [00:00<00:00, 73.37it/s]

[37/100] train loss = 0.10024, train acc = 0.99662 valid loss = 0.08967, valid acc = 0.99219

train epoch[38/100] loss:0.088: 100%|██████████| 37/37 [00:01<00:00, 21.76it/s]

valid epoch[38/100]: 100%|██████████| 12/12 [00:00<00:00, 75.20it/s]

[38/100] train loss = 0.09357, train acc = 0.99578 valid loss = 0.09180, valid acc = 0.98698

train epoch[39/100] loss:0.090: 100%|██████████| 37/37 [00:01<00:00, 21.30it/s]

valid epoch[39/100]: 100%|██████████| 12/12 [00:00<00:00, 72.92it/s]

[39/100] train loss = 0.08565, train acc = 0.99747 valid loss = 0.08579, valid acc = 0.99219

train epoch[40/100] loss:0.094: 100%|██████████| 37/37 [00:01<00:00, 21.52it/s]

valid epoch[40/100]: 100%|██████████| 12/12 [00:00<00:00, 75.67it/s]

[40/100] train loss = 0.07875, train acc = 0.99916 valid loss = 0.07779, valid acc = 0.99479

train epoch[41/100] loss:0.078: 100%|██████████| 37/37 [00:01<00:00, 21.30it/s]

valid epoch[41/100]: 100%|██████████| 12/12 [00:00<00:00, 71.19it/s]

[41/100] train loss = 0.08110, train acc = 0.99662 valid loss = 0.07521, valid acc = 0.99219

train epoch[42/100] loss:0.069: 100%|██████████| 37/37 [00:01<00:00, 20.63it/s]

valid epoch[42/100]: 100%|██████████| 12/12 [00:00<00:00, 75.20it/s]

[42/100] train loss = 0.07253, train acc = 1.00000 valid loss = 0.06846, valid acc = 0.99479

train epoch[43/100] loss:0.069: 100%|██████████| 37/37 [00:01<00:00, 20.83it/s]

valid epoch[43/100]: 100%|██████████| 12/12 [00:00<00:00, 71.62it/s]

[43/100] train loss = 0.07062, train acc = 0.99831 valid loss = 0.06661, valid acc = 0.99479

train epoch[44/100] loss:0.060: 100%|██████████| 37/37 [00:01<00:00, 20.80it/s]

valid epoch[44/100]: 100%|██████████| 12/12 [00:00<00:00, 73.37it/s]

[44/100] train loss = 0.06295, train acc = 0.99916 valid loss = 0.06407, valid acc = 0.99219

train epoch[45/100] loss:0.058: 100%|██████████| 37/37 [00:01<00:00, 20.61it/s]

valid epoch[45/100]: 100%|██████████| 12/12 [00:00<00:00, 57.85it/s]

[45/100] train loss = 0.06356, train acc = 0.99916 valid loss = 0.06337, valid acc = 0.99479

train epoch[46/100] loss:0.048: 100%|██████████| 37/37 [00:01<00:00, 20.41it/s]

valid epoch[46/100]: 100%|██████████| 12/12 [00:00<00:00, 70.35it/s]

[46/100] train loss = 0.05736, train acc = 1.00000 valid loss = 0.05693, valid acc = 0.99479

train epoch[47/100] loss:0.046: 100%|██████████| 37/37 [00:01<00:00, 20.67it/s]

valid epoch[47/100]: 100%|██████████| 12/12 [00:00<00:00, 73.82it/s]

[47/100] train loss = 0.05598, train acc = 0.99831 valid loss = 0.05114, valid acc = 0.99740

train epoch[48/100] loss:0.048: 100%|██████████| 37/37 [00:01<00:00, 20.45it/s]

valid epoch[48/100]: 100%|██████████| 12/12 [00:00<00:00, 72.48it/s]

[48/100] train loss = 0.05222, train acc = 0.99831 valid loss = 0.05625, valid acc = 0.99219

train epoch[49/100] loss:0.060: 100%|██████████| 37/37 [00:01<00:00, 21.32it/s]

valid epoch[49/100]: 100%|██████████| 12/12 [00:00<00:00, 73.82it/s]

[49/100] train loss = 0.04794, train acc = 1.00000 valid loss = 0.05231, valid acc = 0.99479

train epoch[50/100] loss:0.043: 100%|██████████| 37/37 [00:01<00:00, 21.07it/s]

valid epoch[50/100]: 100%|██████████| 12/12 [00:00<00:00, 67.98it/s]

[50/100] train loss = 0.04888, train acc = 0.99916 valid loss = 0.05647, valid acc = 0.99219

train epoch[51/100] loss:0.040: 100%|██████████| 37/37 [00:01<00:00, 21.05it/s]

valid epoch[51/100]: 100%|██████████| 12/12 [00:00<00:00, 73.80it/s]

[51/100] train loss = 0.04834, train acc = 0.99916 valid loss = 0.04408, valid acc = 0.99740

train epoch[52/100] loss:0.041: 100%|██████████| 37/37 [00:01<00:00, 20.77it/s]

valid epoch[52/100]: 100%|██████████| 12/12 [00:00<00:00, 71.20it/s]

[52/100] train loss = 0.04667, train acc = 0.99916 valid loss = 0.04379, valid acc = 0.99479

train epoch[53/100] loss:0.055: 100%|██████████| 37/37 [00:01<00:00, 20.91it/s]

valid epoch[53/100]: 100%|██████████| 12/12 [00:00<00:00, 72.05it/s]

[53/100] train loss = 0.04231, train acc = 0.99916 valid loss = 0.04204, valid acc = 0.99219

train epoch[54/100] loss:0.032: 100%|██████████| 37/37 [00:01<00:00, 19.92it/s]

valid epoch[54/100]: 100%|██████████| 12/12 [00:00<00:00, 65.73it/s]

[54/100] train loss = 0.03975, train acc = 0.99916 valid loss = 0.04106, valid acc = 0.99479

train epoch[55/100] loss:0.031: 100%|██████████| 37/37 [00:01<00:00, 19.72it/s]

valid epoch[55/100]: 100%|██████████| 12/12 [00:00<00:00, 61.08it/s]

[55/100] train loss = 0.04146, train acc = 0.99831 valid loss = 0.03957, valid acc = 0.99740

train epoch[56/100] loss:0.035: 100%|██████████| 37/37 [00:02<00:00, 16.76it/s]

valid epoch[56/100]: 100%|██████████| 12/12 [00:00<00:00, 48.52it/s]

[56/100] train loss = 0.03479, train acc = 1.00000 valid loss = 0.03582, valid acc = 0.99740

train epoch[57/100] loss:0.027: 100%|██████████| 37/37 [00:02<00:00, 14.98it/s]

valid epoch[57/100]: 100%|██████████| 12/12 [00:00<00:00, 69.95it/s]

[57/100] train loss = 0.03489, train acc = 0.99916 valid loss = 0.03444, valid acc = 1.00000

train epoch[58/100] loss:0.032: 100%|██████████| 37/37 [00:01<00:00, 19.35it/s]

valid epoch[58/100]: 100%|██████████| 12/12 [00:00<00:00, 57.85it/s]

[58/100] train loss = 0.03554, train acc = 0.99916 valid loss = 0.03774, valid acc = 0.99219

train epoch[59/100] loss:0.026: 100%|██████████| 37/37 [00:01<00:00, 18.50it/s]

valid epoch[59/100]: 100%|██████████| 12/12 [00:00<00:00, 77.63it/s]

[59/100] train loss = 0.03194, train acc = 1.00000 valid loss = 0.03534, valid acc = 0.99740

train epoch[60/100] loss:0.026: 100%|██████████| 37/37 [00:01<00:00, 19.12it/s]

valid epoch[60/100]: 100%|██████████| 12/12 [00:00<00:00, 67.20it/s]

[60/100] train loss = 0.03171, train acc = 1.00000 valid loss = 0.03281, valid acc = 0.99740

train epoch[61/100] loss:0.038: 100%|██████████| 37/37 [00:02<00:00, 17.62it/s]

valid epoch[61/100]: 100%|██████████| 12/12 [00:00<00:00, 60.77it/s]

[61/100] train loss = 0.03192, train acc = 0.99916 valid loss = 0.03807, valid acc = 0.99219

train epoch[62/100] loss:0.028: 100%|██████████| 37/37 [00:01<00:00, 18.79it/s]

valid epoch[62/100]: 100%|██████████| 12/12 [00:00<00:00, 81.30it/s]

[62/100] train loss = 0.03033, train acc = 0.99916 valid loss = 0.03123, valid acc = 0.99740

train epoch[63/100] loss:0.034: 100%|██████████| 37/37 [00:01<00:00, 18.68it/s]

valid epoch[63/100]: 100%|██████████| 12/12 [00:00<00:00, 53.01it/s]

[63/100] train loss = 0.02704, train acc = 1.00000 valid loss = 0.03206, valid acc = 0.99740

train epoch[64/100] loss:0.024: 100%|██████████| 37/37 [00:01<00:00, 19.03it/s]

valid epoch[64/100]: 100%|██████████| 12/12 [00:00<00:00, 70.36it/s]

[64/100] train loss = 0.02689, train acc = 0.99831 valid loss = 0.02918, valid acc = 0.99740

train epoch[65/100] loss:0.020: 100%|██████████| 37/37 [00:02<00:00, 18.43it/s]

valid epoch[65/100]: 100%|██████████| 12/12 [00:00<00:00, 62.34it/s]

[65/100] train loss = 0.02567, train acc = 0.99916 valid loss = 0.02967, valid acc = 0.99479

train epoch[66/100] loss:0.024: 100%|██████████| 37/37 [00:01<00:00, 19.01it/s]

valid epoch[66/100]: 100%|██████████| 12/12 [00:00<00:00, 65.75it/s]

[66/100] train loss = 0.02429, train acc = 1.00000 valid loss = 0.02723, valid acc = 0.99740

train epoch[67/100] loss:0.023: 100%|██████████| 37/37 [00:01<00:00, 20.66it/s]

valid epoch[67/100]: 100%|██████████| 12/12 [00:00<00:00, 68.36it/s]

[67/100] train loss = 0.02462, train acc = 0.99916 valid loss = 0.02666, valid acc = 0.99740

train epoch[68/100] loss:0.025: 100%|██████████| 37/37 [00:01<00:00, 20.51it/s]

valid epoch[68/100]: 100%|██████████| 12/12 [00:00<00:00, 71.62it/s]

[68/100] train loss = 0.02393, train acc = 1.00000 valid loss = 0.02665, valid acc = 0.99740

train epoch[69/100] loss:0.025: 100%|██████████| 37/37 [00:02<00:00, 17.41it/s]

valid epoch[69/100]: 100%|██████████| 12/12 [00:00<00:00, 66.48it/s]

[69/100] train loss = 0.02368, train acc = 1.00000 valid loss = 0.02783, valid acc = 0.99740

train epoch[70/100] loss:0.023: 100%|██████████| 37/37 [00:01<00:00, 20.67it/s]

valid epoch[70/100]: 100%|██████████| 12/12 [00:00<00:00, 68.75it/s]

[70/100] train loss = 0.02227, train acc = 1.00000 valid loss = 0.02939, valid acc = 0.99479

train epoch[71/100] loss:0.023: 100%|██████████| 37/37 [00:01<00:00, 21.13it/s]

valid epoch[71/100]: 100%|██████████| 12/12 [00:00<00:00, 73.82it/s]

[71/100] train loss = 0.02293, train acc = 0.99916 valid loss = 0.03210, valid acc = 0.99479

train epoch[72/100] loss:0.019: 100%|██████████| 37/37 [00:01<00:00, 21.08it/s]

valid epoch[72/100]: 100%|██████████| 12/12 [00:00<00:00, 67.98it/s]

[72/100] train loss = 0.02295, train acc = 0.99831 valid loss = 0.02529, valid acc = 0.99479

train epoch[73/100] loss:0.017: 100%|██████████| 37/37 [00:01<00:00, 20.52it/s]

valid epoch[73/100]: 100%|██████████| 12/12 [00:00<00:00, 75.20it/s]

[73/100] train loss = 0.01929, train acc = 1.00000 valid loss = 0.02114, valid acc = 0.99740

train epoch[74/100] loss:0.014: 100%|██████████| 37/37 [00:01<00:00, 18.94it/s]

valid epoch[74/100]: 100%|██████████| 12/12 [00:00<00:00, 72.05it/s]

[74/100] train loss = 0.01884, train acc = 1.00000 valid loss = 0.01829, valid acc = 1.00000

train epoch[75/100] loss:0.017: 100%|██████████| 37/37 [00:01<00:00, 21.02it/s]

valid epoch[75/100]: 100%|██████████| 12/12 [00:00<00:00, 72.03it/s]

[75/100] train loss = 0.01927, train acc = 1.00000 valid loss = 0.02181, valid acc = 0.99479

train epoch[76/100] loss:0.015: 100%|██████████| 37/37 [00:01<00:00, 20.97it/s]

valid epoch[76/100]: 100%|██████████| 12/12 [00:00<00:00, 71.60it/s]

[76/100] train loss = 0.01836, train acc = 1.00000 valid loss = 0.02229, valid acc = 0.99479

train epoch[77/100] loss:0.014: 100%|██████████| 37/37 [00:02<00:00, 17.26it/s]

valid epoch[77/100]: 100%|██████████| 12/12 [00:00<00:00, 70.78it/s]

[77/100] train loss = 0.01834, train acc = 1.00000 valid loss = 0.02153, valid acc = 0.99479

train epoch[78/100] loss:0.020: 100%|██████████| 37/37 [00:01<00:00, 20.81it/s]

valid epoch[78/100]: 100%|██████████| 12/12 [00:00<00:00, 68.35it/s]

[78/100] train loss = 0.01873, train acc = 0.99916 valid loss = 0.02506, valid acc = 0.99479

train epoch[79/100] loss:0.014: 100%|██████████| 37/37 [00:01<00:00, 21.67it/s]

valid epoch[79/100]: 100%|██████████| 12/12 [00:00<00:00, 72.48it/s]

[79/100] train loss = 0.01737, train acc = 1.00000 valid loss = 0.01964, valid acc = 0.99740

train epoch[80/100] loss:0.027: 100%|██████████| 37/37 [00:01<00:00, 21.11it/s]

valid epoch[80/100]: 100%|██████████| 12/12 [00:00<00:00, 72.05it/s]

[80/100] train loss = 0.01733, train acc = 1.00000 valid loss = 0.01674, valid acc = 1.00000

train epoch[81/100] loss:0.013: 100%|██████████| 37/37 [00:01<00:00, 21.31it/s]

valid epoch[81/100]: 100%|██████████| 12/12 [00:00<00:00, 77.61it/s]

[81/100] train loss = 0.01643, train acc = 1.00000 valid loss = 0.01542, valid acc = 1.00000

train epoch[82/100] loss:0.015: 100%|██████████| 37/37 [00:01<00:00, 20.96it/s]

valid epoch[82/100]: 100%|██████████| 12/12 [00:00<00:00, 72.48it/s]

[82/100] train loss = 0.01495, train acc = 1.00000 valid loss = 0.01967, valid acc = 0.99479

train epoch[83/100] loss:0.016: 100%|██████████| 37/37 [00:01<00:00, 21.32it/s]

valid epoch[83/100]: 100%|██████████| 12/12 [00:00<00:00, 72.92it/s]

[83/100] train loss = 0.01611, train acc = 0.99916 valid loss = 0.01737, valid acc = 0.99479

train epoch[84/100] loss:0.013: 100%|██████████| 37/37 [00:01<00:00, 21.37it/s]

valid epoch[84/100]: 100%|██████████| 12/12 [00:00<00:00, 76.15it/s]

[84/100] train loss = 0.01402, train acc = 1.00000 valid loss = 0.01789, valid acc = 0.99740

train epoch[85/100] loss:0.011: 100%|██████████| 37/37 [00:01<00:00, 21.59it/s]

valid epoch[85/100]: 100%|██████████| 12/12 [00:00<00:00, 72.92it/s]

[85/100] train loss = 0.01373, train acc = 1.00000 valid loss = 0.02572, valid acc = 0.99479

train epoch[86/100] loss:0.020: 100%|██████████| 37/37 [00:01<00:00, 21.49it/s]

valid epoch[86/100]: 100%|██████████| 12/12 [00:00<00:00, 72.03it/s]

[86/100] train loss = 0.01379, train acc = 1.00000 valid loss = 0.01887, valid acc = 0.99740

train epoch[87/100] loss:0.014: 100%|██████████| 37/37 [00:01<00:00, 19.90it/s]

valid epoch[87/100]: 100%|██████████| 12/12 [00:00<00:00, 72.48it/s]

[87/100] train loss = 0.01300, train acc = 1.00000 valid loss = 0.01850, valid acc = 0.99740

train epoch[88/100] loss:0.011: 100%|██████████| 37/37 [00:01<00:00, 18.70it/s]

valid epoch[88/100]: 100%|██████████| 12/12 [00:00<00:00, 53.01it/s]

[88/100] train loss = 0.01252, train acc = 1.00000 valid loss = 0.01938, valid acc = 0.99479

train epoch[89/100] loss:0.012: 100%|██████████| 37/37 [00:01<00:00, 19.00it/s]

valid epoch[89/100]: 100%|██████████| 12/12 [00:00<00:00, 75.20it/s]

[89/100] train loss = 0.01472, train acc = 0.99747 valid loss = 0.02491, valid acc = 0.99479

train epoch[90/100] loss:0.011: 100%|██████████| 37/37 [00:01<00:00, 20.91it/s]

valid epoch[90/100]: 100%|██████████| 12/12 [00:00<00:00, 70.78it/s]

[90/100] train loss = 0.01350, train acc = 1.00000 valid loss = 0.01387, valid acc = 1.00000

train epoch[91/100] loss:0.012: 100%|██████████| 37/37 [00:01<00:00, 21.16it/s]

valid epoch[91/100]: 100%|██████████| 12/12 [00:00<00:00, 69.55it/s]

[91/100] train loss = 0.01305, train acc = 1.00000 valid loss = 0.03113, valid acc = 0.99479

train epoch[92/100] loss:0.011: 100%|██████████| 37/37 [00:01<00:00, 20.76it/s]

valid epoch[92/100]: 100%|██████████| 12/12 [00:00<00:00, 70.36it/s]

[92/100] train loss = 0.01209, train acc = 1.00000 valid loss = 0.04791, valid acc = 0.98958

train epoch[93/100] loss:0.010: 100%|██████████| 37/37 [00:01<00:00, 21.03it/s]

valid epoch[93/100]: 100%|██████████| 12/12 [00:00<00:00, 72.05it/s]

[93/100] train loss = 0.01593, train acc = 0.99831 valid loss = 0.04162, valid acc = 0.98958

train epoch[94/100] loss:0.010: 100%|██████████| 37/37 [00:01<00:00, 21.75it/s]

valid epoch[94/100]: 100%|██████████| 12/12 [00:00<00:00, 76.15it/s]

[94/100] train loss = 0.01366, train acc = 0.99916 valid loss = 0.03043, valid acc = 0.99479

train epoch[95/100] loss:0.010: 100%|██████████| 37/37 [00:01<00:00, 19.49it/s]

valid epoch[95/100]: 100%|██████████| 12/12 [00:00<00:00, 55.70it/s]

[95/100] train loss = 0.01159, train acc = 1.00000 valid loss = 0.01456, valid acc = 0.99479

train epoch[96/100] loss:0.010: 100%|██████████| 37/37 [00:01<00:00, 19.23it/s]

valid epoch[96/100]: 100%|██████████| 12/12 [00:00<00:00, 53.71it/s]

[96/100] train loss = 0.01044, train acc = 1.00000 valid loss = 0.01179, valid acc = 1.00000

train epoch[97/100] loss:0.010: 100%|██████████| 37/37 [00:01<00:00, 19.80it/s]

valid epoch[97/100]: 100%|██████████| 12/12 [00:00<00:00, 77.63it/s]

[97/100] train loss = 0.01049, train acc = 1.00000 valid loss = 0.01203, valid acc = 1.00000

train epoch[98/100] loss:0.011: 100%|██████████| 37/37 [00:01<00:00, 19.81it/s]

valid epoch[98/100]: 100%|██████████| 12/12 [00:00<00:00, 76.64it/s]

[98/100] train loss = 0.01043, train acc = 1.00000 valid loss = 0.01578, valid acc = 0.99740

train epoch[99/100] loss:0.010: 100%|██████████| 37/37 [00:01<00:00, 19.14it/s]

valid epoch[99/100]: 100%|██████████| 12/12 [00:00<00:00, 64.00it/s]

[99/100] train loss = 0.01027, train acc = 1.00000 valid loss = 0.01219, valid acc = 0.99740

train epoch[100/100] loss:0.007: 100%|██████████| 37/37 [00:01<00:00, 20.18it/s]

valid epoch[100/100]: 100%|██████████| 12/12 [00:00<00:00, 78.13it/s]

[100/100] train loss = 0.00954, train acc = 1.00000 valid loss = 0.01715, valid acc = 0.99479

代码见评论区

擅长现代信号处理(改进小波分析系列,改进变分模态分解,改进经验小波变换,改进辛几何模态分解等等),改进机器学习,改进深度学习,机械故障诊断,改进时间序列分析(金融信号,心电信号,振动信号等)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/413988
推荐阅读
相关标签
  

闽ICP备14008679号