当前位置:网站首页>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 .
边栏推荐
- Use REM to make the font size adaptive to the screen
- Att & CK Threat Intelligence
- Sword finger offer II 067. maximum XOR (medium prefix tree bit operation array)
- SSH password free login
- Ultra detailed visual studio 2019 running littlevgl (lvgl) simulator
- [connect set-top box] - use ADB command line to connect ec6108v9 Huawei Yuehe box wirelessly
- Sword finger offer II 064. magic Dictionary (medium dictionary tree string design)
- Which is the file transfer command in the basic services of the Internet
- Mysql8.0 cannot authorize users or prompt you are not allowed to create a user with grant
- GD32F303固件库开发(10)----双ADC轮询模式扫描多个通道
猜你喜欢

STM32 board level support package for keys

Command line agent: proxychains configuration

MySQL built-in functions

Qt+FFmpeg环境搭建

STM32 - interrupt overview (interrupt priority)

Static details of static members

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

Att & CK preliminary understanding

STM32 - external interrupt application (exti) (use cubemx to configure interrupts)

JMeter installs third-party plug-ins plugins Manager
随机推荐
How to install WiFi correctly
Netease Yunxin 2022q2 product supply station, come and get your product supply plan!
STM32 -- program startup process
There will be a black line on the border when the button in the wechat applet is clicked
微信小程序剪切图片的功能
静态成员static详解
Summary of common error types in JS
Sword finger offer II 064. magic Dictionary (medium dictionary tree string design)
Chrome encountered a problem when debugging the code. After modifying and saving the code in vscode, chrome did not update after refreshing
JS array merging, de duplication, dimensionality reduction (es6: extended operator, set)
mysql8.0无法给用户授权或提示You are not allowed to create a user with GRANT的问题
【转载】token令牌在登录场景使用
Static details of static members
elment-plus图标input上面带的图标为什么不显示
Sword finger offer II 055. Binary search tree iterator (medium binary search tree iterator)
Soft exam network engineer
[connect your mobile phone wirelessly] - debug your mobile device wirelessly via LAN
Binary source code, inverse code, complement code
JS获取当前时间(年月日时分秒)
C language to realize string reverse order arrangement