当前位置:网站首页>Differernet [anomaly detection: normalizing flow]
Differernet [anomaly detection: normalizing flow]
2022-07-28 22:41:00 【It's too simple】
Preface
The blog is from 2020.8CVPR A paper on ,papers with code Statistical in MVTec The data set is ranked 20( As of the time of posting ), Now let's use Normalizing Flow Most of the network architecture testing results of the main ideas are in the forefront . This article mainly aims at DifferNet Understand the network operation architecture , There is no introduction to loss function and experiment .
background
The idea of network combines neural network feature extraction and standardized flow for density estimation , Solve the problem that defects cannot be detected by traditional methods using high intra class variance .
Standardized flow is a kind of neural network that can realize the transformation from data to density estimation , It is characterized by convenient propagation in two directions . There are two ways to implement affine transformation layer ( Autoregression and fixation ).RealNVP It is a special kind of inverse autoregressive flow . This article USES the RealNVP Structure and design an exponential function to make the training converge better .
The network proposes a classification of anomaly detection models based on generation model and pre training network . This network is the first batch of networks that use standardized flow for anomaly detection ..
Source code principle ( The model part )
Find the function input , Understand trunk functions , The following is understood with reference to the figure below .

class DifferNet(nn.Module)
batchsize Set to 24, After image enhancement *4, That is, one-time input model 96 A picture , Be careful 96 Map processing at the same time . Each picture is sampled into 1/1,1/2 and 1/4 size , After that, three down sampled pictures passed AlexNet Network feature extraction , Average all pixel values of each channel of the extracted feature map , Because it is 96 Map processing at the same time , formation (96,256) tensor , Three pictures cat Post formation (96,768) tensor .
def nf_head(input_dim=c.n_feat)
structure 10 A flow block ,8 individual NormalizingFlow Flow block ,1 individual Input fast ,1 individual output block .8 Each flow block is a consistent structure :
(1)class permute_layer(nn.Module)
take 0~768 Make two disorderly permutations of numbers , There is a law between these two disordered permutations , One is random disorder , The other made another disorder based on random disorder .
(2)class glow_coupling_layer(nn.module)
take 768 The dimension is divided into two halves (0~364,364~768), The latter half is activated by full connection ,s2,t2 Divide the latter half into half , According to the formula in the original paper (1) With the first half 768 Dimension calculation version . After the computing version is activated by full connection ,s1,t1 Divide the calculation version in half , According to the formula in the original paper (1) Calculate with the first half to generate the final version . Combine the calculated version with the final version in a column , And limit the range of values after combination .
1)class F_fully_connected(nn.Module)
Four floors are fully connected , The whole company hierarchy has Dropout Probabilistic reduction in the number of neurons , Prevent over fitting , The last layer does not set the activation function , Not set up Dropout.
2)def log_e(self,s)
The exponential function mentioned above , The formula of the original paper (2), Limit the value of the dimension to (-3,3) Between .
tips( Source code some interesting program segments )
(1) The parent class calls the child class
Source code segment
if not self.input_dims: # Only do it if this hasn't been computed yet
self.input_dims = [n.build_modules(verbose=verbose)[c]
for n, c in self.inputs]explain
self.inputs yes InputNode.out0, Look back InputNode In class self.out0 = (self, 0), That is to say n representative self This class itself ,c representative 0, adopt build_modules Function returns the input dimension 768.
(2)96 Transformation of tensor form of picture ( namely torch.Size([24, 4, 3, 448, 448])-->torch.Size([96, 3, 448, 448]))
Source code segment
inputs = inputs.view(-1, *inputs.shape[-3:])explain
*: Represents the input of arguments
view:-1 It means that the value here is not determined , Determine according to the later determined value ,(24,4,...) To (96,...) The source code completes the conversion .
边栏推荐
- When can I sign up for the 2022 class I constructor examination?
- Kali source solution software cannot be installed correctly
- 容器化配置启动redis集群 单机6节点 3主3从
- Closure, prototype and original link
- Is mov format a still image file format
- Paddlenlp text classification based on ernir3.0: take wos dataset as an example (hierarchical classification)
- winform跳转第二个窗体案例
- PaddleNLP基于ERNIR3.0文本分类以中医疗搜索检索词意图分类(KUAKE-QIC)为例【多分类(单标签)】
- winServer运维技术栈
- Excel-vba quick start (XIII. Common usage of date)
猜你喜欢

Can the MySQL create statement be used to create a table structure and append new records

JVM——自定义类加载器

PaddleNLP基于ERNIR3.0文本分类:WOS数据集为例(层次分类)

使用PCL批量将点云.bin文件转.pcd

96. Different binary search trees (medium binary search tree dynamic planning)

2022年一级建造师考试什么时候才能报名?

ATT&CK初步了解

软考网络工程师

Baidu map usage

Qt+ffmpeg environment construction
随机推荐
Detection and tracking evaluation index
Sword finger offer II 055. Binary search tree iterator (medium binary search tree iterator)
[connect set-top box] - use ADB command line to connect ec6108v9 Huawei Yuehe box wirelessly
c语言实现字符串逆序排列
Sword finger offer II 056. Sum of two nodes in a binary search tree (simple binary search tree DFS hash table double pointer iterator)
Redis related
微信小程序使用canvas绘图,圆形头像,网络背景图,文字,虚线,直线
STM32 - systick timer (cubemx configures systick)
Sword finger offer II 066. sum of words (medium prefix tree design string)
STM32 board level support package for keys
Sword finger offer II 053. Medium order successor in binary search tree (medium binary search tree DFS)
For loops and functions
Command line agent: proxychains configuration
76. Minimum coverage substring (hard sliding window hash table string)
Sword finger offer II 052. flatten binary search tree (simple binary search tree DFS)
775. 倒排单词
STM32 - DMA direct memory access controller (cubemx configures DMA)
微信小程序里button点击的时候会边框有黑线
近期bug总结
771. 字符串中最长的连续出现的字符