当前位置:网站首页>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 .
边栏推荐
- ES6 concept
- ATT&CK初步了解
- Why doesn't the icon on the elment plus icon input display
- fatal error: io. h: No such file or directory
- 二进制的原码、反码、补码
- 6K6w5LiA5qyh5pS75Ye75YiG5p6Q
- [Ruiji takeout project]day4 - dish management
- [virtual machine _2]-hyper-v and vmware/virtualbox cannot coexist
- CMD common commands
- 微信小程序里button点击的时候会边框有黑线
猜你喜欢

Sword finger offer II 053. Medium order successor in binary search tree (medium binary search tree DFS)

静态成员static详解

MySQL installation and configuration (super detailed, simple and practical)

C language to realize string reverse order arrangement

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

Qt+ffmpeg environment construction

Att & CK preliminary understanding

JVM——自定义类加载器

2022年一级建造师考试什么时候才能报名?
![[Ruiji takeout project]day4 - dish management](/img/2a/2d9deb7a583aa37b38a67ef2c74ee7.png)
[Ruiji takeout project]day4 - dish management
随机推荐
Binary source code, inverse code, complement code
Why doesn't the icon on the elment plus icon input display
For loops and functions
SSH password free login
JS array merging, de duplication, dimensionality reduction (es6: extended operator, set)
Which is the file transfer command in the basic services of the Internet
96. Different binary search trees (medium binary search tree dynamic planning)
[Ruiji takeout] day05 package management business development
MySQL command (add, delete, check and modify)
纪念一下第一次写的线段树了喽(对应洛谷3372)
Awk blank line filtering
Sword finger offer II 057. the difference between the value and the subscript is within the given range (medium array bucket sort sliding window TreeSet)
Static details of static members
Solve the problem that TS node xxx.ts executes TS code and reports errors
Concise history of graphic technology
Ngx+sql environment offline installation log (RPM installation)
Research cup element recognition multi label classification task based on ernie-3.0 cail2019 method
Qt+FFmpeg环境搭建
XXX port is already in use
[virtual machine _2]-hyper-v and vmware/virtualbox cannot coexist