当前位置:网站首页>Anomaly-Transformer (ICLR 2022 Spotlight)复现过程及问题
Anomaly-Transformer (ICLR 2022 Spotlight)复现过程及问题
2022-07-01 22:56:00 【理心炼丹】
作者推荐的是 python3.6,pytorch 1.4
1. 环境修改
尝试安装 pytorch 1.4 运行,但是代码会卡住,并且没有报错。定位错误在:Anomaly-Transformer/model/attn.py
self.distances = torch.zeros((window_size, window_size)).cuda().cuda() 卡住:原因是 安装的 pytorch 1.4 对应的CUDA 版本为 10.x,算力是 sm_86,CUDA 10.x 最高支持到 sm_75,因此需要CUDA 11.x来支持sm_8.x。
因此升级 我的环境 python3.7, pytorch 1.12 , 显卡3080Ti, CUDA 版本:11.3
conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch再次运行训练脚本,又报错:
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [512, 25]], which is output 0 of AsStridedBackward0, is at version 2; expected version 1 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).
解决:注释掉Anomaly-Transformer/solver.py 的第一个 .step():
# Minimax strategy
loss1.backward(retain_graph=True)
# self.optimizer.step()
loss2.backward()
self.optimizer.step()参考:Why the optimizer.step() write twice? · Issue #8 · thuml/Anomaly-Transformer · GitHub
2. 恭喜! 成功运行!
python main.py --anormly_ratio 1 --num_epochs 3 --batch_size 128 --mode train --dataset PSM --data_path dataset/PSM --input_c 25 --output_c 25------------ Options -------------
anormly_ratio: 1.0
batch_size: 128
data_path: dataset/PSM
dataset: PSM
input_c: 25
k: 3
lr: 0.0001
mode: train
model_save_path: checkpoints
num_epochs: 3
output_c: 25
pretrained_model: None
win_size: 100
======================TEST MODE======================
/opt/conda/lib/python3.7/site-packages/torch/nn/_reduction.py:42: UserWarning: size_average and reduce args will be deprecated, please use reduction='none' instead.
warnings.warn(warning.format(ret))
Threshold : 0.002150955616962149
pred: (87800,)
gt: (87800,)
pred: (87800,)
gt: (87800,)
Accuracy : 0.9848, Precision : 0.9713, Recall : 0.9739, F-score : 0.9726
论文中的结果:对于PSM数据集
P: 96.91,R: 98.9, F1: 97.89
复现的 Recall 略低。但是 Precision 略高。二者本就是需要权衡。可以通过调整上面的 Threshold : 0.002150955616962149 平衡二者。
边栏推荐
- ShanDong Multi-University Training #3
- What is mosaic?
- 【小程序】通过scroll-view组件实现左右【滑动】列表
- Jielizhi, production line assembly link [chapter]
- CADD course learning (3) -- target drug interaction
- from pip._internal.cli.main import main ModuleNotFoundError: No module named ‘pip‘
- Zhongang Mining: it has inherent advantages to develop the characteristic chemical industry dominated by fluorine chemical industry
- [MySQL] basic use of explain and the function of each column
- Postgresql源码(58)元组拼接heap_form_tuple剖析
- Postgresql源码(57)HOT更新为什么性能差距那么大?
猜你喜欢
![Jielizhi, production line assembly link [chapter]](/img/5f/9ea7fd3b93df1fd3ecbfc1b669c831.png)
Jielizhi, production line assembly link [chapter]

"35 years old, the boss of the company, with a monthly salary of 20000, give away takeout": the times abandoned you, not even saying goodbye

Matplotlib常用设置

YOGA27多维一体电脑,兼具出色外观与高端配置

实在RPA:银行数字化,业务流程自动化“一小步”,贷款审核效率“一大步”

Future trend and development of neural network Internet of things

Three development trends of enterprise application from the perspective of the third technological revolution

马赛克后挡板是什么?

日本购物网站的网络乞丐功能

Distance measurement - Hamming distance
随机推荐
内存泄露和内存溢出的区别是什么?
微信个人小商店一键开通助手小程序开发
Zhongang Mining: it has inherent advantages to develop the characteristic chemical industry dominated by fluorine chemical industry
CKS CKA CKAD 将终端更改为远程桌面
y53.第三章 Kubernetes从入门到精通 -- ingress(二六)
【小程序】通过scroll-view组件实现左右【滑动】列表
Aaai22 | structural tagging and interaction modeling: a "slim" network for graph classification
赵福全:短期解决保供,长期要打造安全、高效有韧性的供应链
MySQL binlog cleanup
typescript枚举
问题随记 —— /usr/bin/perl is needed by MySQL-server-5.1.73-1.glibc23.x86_64
[understanding of opportunity-35]: Guiguzi - flying clamp - the art of remote connection, remote control and remote testing
Glass mosaic
Wechat personal small store one click opening assistant applet development
云信小课堂 | IM及音视频中常见的认知误区
Leetcode(34)——在排序数组中查找元素的第一个和最后一个位置
Postgresql源码(57)HOT更新为什么性能差距那么大?
Y53. Chapter III kubernetes from introduction to mastery -- ingress (26)
Yunxin small class | common cognitive misunderstandings in IM and audio and video
[applet] realize the left and right [sliding] list through the scroll view component