源码地址:https://github.com/donggong1/memae-anomaly-detection
问题提出
''It has been observed that sometimes the autoencoder “generalizes” so well that it can also reconstruct anomalies well, leading to the miss detection of anomalies ‘’
“The assumption that anomaly incurs higher reconstruction error might be somehow questionable since there are no training samples for anomalies and the reconstruction behavior for anomaly inputs should be unpredictable."
当前基于reconstruction error的方法,因为ae存在的泛化性能,导致anomaly data也可能具有较小的重构损失,检测效果较差。
问题解决
- 通过memory机制改善autoencoder
在训练过程中利用训练样本更新一个memory bank,该memory bank用来表示normal样本的prototype。测试过程中,memory bank固定,对某一个测试样本搜索一些prototypes并加权求和,代表该测试样本,并进行重构误差计算。(因为是利用normal prototype进行重构,因此对于异常样本,重构损失肯定会增加)
- attention based memory addressing来寻找most relevant items in memory bank
- hard shrinkage operator to induce sparsity of memory addressing weights
模型结构
-
encoder
f e : X → Z z = f e ( x ; θ e ) f_e : X \rightarrow Z \\ z = f_e(x;\theta_e) fe:X→Zz=fe(x;θe)
z既是x的表征,同时也作为query,在memory bank中搜索最相关的prototype -
decoder
x ^ = f d ( z ^ ; θ d ) \hat{x}=f_d(\hat{z};\theta_d) x^=f