当前位置:网站首页>Superficial understanding of conditional random fields
Superficial understanding of conditional random fields
2022-06-13 02:19:00 【Researcher-Du】
Conditional random field (Conditional Random Field,CRF) It is the basic model of naturallanguageprocessing , Is an undirected graph probability model . After long-term development, it has been widely used in part of speech tagging 、 Image classification and many other scenes .
One 、 Basic concepts
Random Airport : Given a set of random variables : X = { X 1 , X 2 , X 3 . . . , X n } X = \{X_1,X_2,X_3...,X_n\} X={ X1,X2,X3...,Xn}, Every random variable X i X_i Xi It can be in another set Y = { Y 1 , Y 2 , Y 3 . . . , Y m } Y = \{Y_1,Y_2,Y_3...,Y_m\} Y={ Y1,Y2,Y3...,Ym} Random values in . Take an example of image classification : You can take all pixels of an image as random variables : I = { I 1 , I 2 , I 3 . . . , I n } I = \{I_1,I_2,I_3...,I_n\} I={ I1,I2,I3...,In} , All categories are : C = { C 1 , C 2 , C 3 . . . , C m } C = \{C_1,C_2,C_3...,C_m\} C={ C1,C2,C3...,Cm}, So image classification is actually a category for each pixel , Therefore, it can be regarded as a random airport .
Markov random Airport : Special case of random airport , It assumes that the value of a certain position in the random field is only related to the value of its adjacent position , Independent of other locations . For example, the above example of image classification , The classification of a pixel , Only follow the surrounding 8 The classification of neighborhood pixels is related to other pixels .
Conditional random field : Given a random variable X X X The value of , If random variable Y Y Y It's a Markov random airport , It's called conditional probability distribution P ( Y ∣ X ) P(Y|X) P(Y∣X) It's conditional random airport . That is, the conditional random field is a conditional probability distribution model of another set of output sequences given a set of input sequences . As in the above example of image classification , Generally, the pixel color information of a given image I I I , Predict each pixel I i I_i Ii The category of can be regarded as a strip random field .
Two 、 Potential function
Given the following random field :
The edges in the graph indicate that the nodes are related to each other , This relationship is two-way 、 symmetrical . Such as : x 3 x_3 x3 and x 5 x_5 x5 There are edges between them , be x 3 x_3 x3 and x 5 x_5 x5 There is a correlation , This correlation is measured by potential function . for example , The following potential functions can be defined :
ψ ( x 3 , x 5 ) = { 2 x 3 = x 5 0.1 o t h e r w i s e \psi(x_3,x_5) = \begin{cases} 2 & x_3 = x_5 \\ 0.1 & otherwise \end{cases} ψ(x3,x5)={ 20.1x3=x5otherwise
Then it shows that the model prefers variables x 3 x_3 x3 and x 5 x_5 x5 Have the same value , The potential function describes the correlation between local variables , It can also be understood as the local soft constraints of the model . To satisfy nonnegativity , Exponential functions are often used to define potential functions :
ψ ( x ) = e − H ( x ) \psi(x) =e^{-H(x)} ψ(x)=e−H(x)
3、 ... and 、 The main target
Our goal is to calculate the maximum a posteriori probability P ( Y ∣ X ) P(Y|X) P(Y∣X), I.e. given X X X after , The most correct classification result Y Y Y, bring P ( Y ∣ X ) P(Y|X) P(Y∣X) Get the maximum .
So how to solve such a probability problem ?
To solve a given probabilistic undirected graph model , We want to write the global joint probability as the product of several sub joint probabilities , That is, factoring the probability graph , This is convenient for the learning and calculation of the model . As a matter of fact , The most important feature of probabilistic undirected graph model is that it is convenient for factorization . In the actual calculation process , An undirected graph is generally divided into cliques one by one ( group (clique) Is a complete subgraph of an undirected graph , Since it is a complete graph , Of course, every pair of vertices must be connected by an edge . Pictured 1 Medium { x 2 , x 3 , x 5 } \{x_2,x_3,x_5\} { x2,x3,x5}, { x 3 , x 4 , x 5 } \{x_3,x_4,x_5\} { x3,x4,x5}, And all subgraphs composed of two adjacent vertices ), And define the potential function on each clique to calculate the maximum probability .
Here we introduce the words in the paper :
How to calculate is not expanded , You can refer to the paper :Efficient inference in fully connected crfs with gaussian edge potentials.
Four 、DenseCRF
The paper :Efficient inference in fully connected crfs with gaussian edge potentials[J]. .
Code :https://github.com/heiwang1997/DenseCRF
DenseCRF This is the paper at the end of the last section , The effect on image classification is very good and efficient . The general classification effect is shown in the figure below 3 Shown , It should be noted that the input here already contains the classification of the initial pixels ,CRF The pixels are reclassified accurately . You can see the 4 Column DenseCRF The classification is very precise .
Basic CRF The model consists of a first-order potential function ( Classification trend of single variable ) Graph model composed of potential function composed of adjacent elements , Obviously , On the image task , One disadvantage of this model is that it only considers adjacent neighborhood elements , Not considering the whole .
DenseCRF It is proposed to connect each pixel with all other pixels , Achieve dense full connection model , For more accurate classification . But at the same time , Will result in too many sides , Therefore, this paper also provides an efficient algorithm , But there is no further introduction in this article , Just a simple introduction DenseCRF The design of the .
Look at the picture 2 The original English part of , The maximum a posteriori probability actually required P ( Y ∣ X ) P(Y|X) P(Y∣X) It's equivalent to asking for E ( X ) E(X) E(X) The minimum value of , So it is actually a problem of energy minimization . and DenseCRF The energy function of is expressed as :
E ( x ) = ∑ i ψ u ( x i ) + ∑ i < j ψ p ( x i , x j ) E(x) = \sum_{i}\psi_u(x_i) + \sum_{i<j}\psi_p(x_i, x_j) E(x)=i∑ψu(xi)+i<j∑ψp(xi,xj)
The energy function consists of two terms : The former is called univariate potential function (unary potential function), The latter is called binary potential function (pairwise potential function).
Unary potential function: Each pixel is associated with a nary potential, Represents the classification loss of each pixel . If a pixel I i I_i Ii Get the correct classification , Then the pixel's unary Loss ψ u ( x i ) \psi_u(x_i) ψu(xi) smaller . This item mainly penalizes the wrong pixel classification .
Pairwise potential function: Any two pixels are associated with a pairwise potential, Used to punish two pixels with different labels .1) If two labels are different pixels , Their texture 、 shape 、 Color 、 The location is quite different , Then the punishment is less , It is hoped that this classification will be maintained ;2) conversely , If these properties are very close , Then the punishment is greater , In fact, I hope they can be reclassified into the same category .
Pairwise potential function The definition and explanation of the word are posted directly to the original text :
Reference material
[1] You know :CRF The principle of conditional random field 、 Example 、 Formula derivation and application
[2] You know : How to easily and pleasantly understand the condition of random airport (CRF)?
[3] You know : Fully understand the conditional random fields (CRF): principle 、 Application, for example, 、CRF++ Realization
[4] CSDN: Markov random field of probability graph (Markov Random Field,MRF)
[5] CSDN: Markov random Airport MRF
[6] You know :FCN(3)—DenseCRF
[7] You know :FCN(5)—DenseCRF deduction
边栏推荐
- cmake_ example
- 【LeetCode-SQL】1532. Last three orders
- Basic exercises of test questions letter graphics ※
- Paper reading - beat tracking by dynamic programming
- Record: how to solve the problem of "the system cannot find the specified path" in the picture message uploaded by transferto() of multipartfile class [valid through personal test]
- regular expression
- Fast Color Segementation
- How to solve the problem of obtaining the time through new date() and writing out the difference of 8 hours between the database and the current time [valid through personal test]
- Application and examples of C language structure
- [pytorch] kaggle large image dataset data analysis + visualization
猜你喜欢

Gadgets: color based video and image cutting
![[work with notes] NDK compiles the open source library ffmpeg](/img/24/ed33e12a07e001fc708e0c023e479c.jpg)
[work with notes] NDK compiles the open source library ffmpeg

1、 Set up Django automation platform (realize one click SQL execution)

Cumulative tax law: calculate how much tax you have paid in a year

Barrykay electronics rushes to the scientific innovation board: it is planned to raise 360million yuan. Mr. and Mrs. Wang Binhua are the major shareholders

Armv8-m learning notes - getting started
![[open source] libinimini: a minimalist ini parsing library for single chip computers](/img/99/f2ded6c189bd45ea6c1e9f86fd64c1.jpg)
[open source] libinimini: a minimalist ini parsing library for single chip computers

When AI meets music, iFLYTEK music leads the industry reform with technology

Paper reading - beat tracking by dynamic programming
![[pytorch]fixmatch code explanation - data loading](/img/0f/1165dbe4c7410a72d74123ec52dc28.jpg)
[pytorch]fixmatch code explanation - data loading
随机推荐
Cumulative tax law: calculate how much tax you have paid in a year
C language volatile learning
STM32 steering gear controller
An image is word 16x16 words: transformers for image recognition at scale
1000粉丝啦~
[learning notes] xr872 audio driver framework analysis
The execution results of i+=2 and i++ i++ under synchronized are different
In addition to the full screen without holes under the screen, the Red Devils 7 series also has these black technologies
Huawei equipment is configured with dual reflectors to optimize the backbone layer of the virtual private network
记录:如何解决MultipartFile类的transferTo()上传图片报“系统找不到指定的路径“问题【亲测有效】
Armv8-m (Cortex-M) TrustZone summary and introduction
Laptop touch pad operation
Basic exercises of test questions letter graphics ※
[programming idea] communication interface of data transmission and decoupling design of communication protocol
[Dest0g3 520迎新赛] 拿到WP还整了很久的Dest0g3_heap
蓝牙模块:使用问题集锦
Armv8-m learning notes - getting started
Yovo3 and yovo3 tiny structure diagram
Vivo released originos ocean, and the domestic customized system is getting better and better
CCF 201409-1: adjacent number pairs (100 points + problem solving ideas)