[关闭]
@hshustc 2015-09-22T16:55:28.000000Z 字数 1935 阅读 3849

条件随机场(Conditional Random Fields)入门

MachineLearning


此文中将以CRF在论文Class Segmentation and Object Localization with Superpixel Neighborhoods中的应用为例,来简要介绍CRF的应用,该论文对应的代码Blocks可在网上下载到。

模型

只关注论文中"Refinement with a CRF"部分, 引用文章中的原话(懒得翻译了……)
"let P(c|G;w) be the conditional probability of the set of class label assignments c given the adjacency graph G(S,E) and a weight w:"

log(P(c|G;w))=siSΨ(ci|si)+w(si,sj)EΦ(ci,cj|si,sj)

"Our unary potentials edge Ψ are defined directly by the probability outputs provided by the our SVM for each superpixel:"
Ψ(ci|si)=log(P(ci|si))

"and our pairwise edge potentials Φ are similar to those:"
Φ(ci,cj|si,sj)=(L(si,sj)1+||sisj||)[cicj]

"where [.] is the zero-one indicator function and ||sisj|| is the norm of the color difference between superpixels in the LUV colorspace. L(si,sj) is the shared boundary length between superpixels si and sj and acts here as a regularizing term which discourages small isolated regions."
"In many CRF applications for this domain, the unary and pairwise potentials are represented by a weighted summation of many simple features, and so the parameters of the model are learned by maximizing their conditional log-likelihood. In our formulation, we simply have one weight w which represents the tradeoff between spatial regularization and our confidence in the classification. We estimate w by cross validation on the training data. Once our model has been learned, we carry out inference with multi-label graph optimization library using α-expansion. Since the CRF is defined on the superpixel graph, inference is very efficient, taking less than half a second per image".

代码

Blocks中的CRF部分是借助实现的, 关于GCMex的说明可参加GCMex代码主页。具体的调用过程参见Blocksexperiments/run_quickrec.m->quichrec.m 270-304行。附件中是配置完成的Blocks代码,其代码还是比较简洁易懂的。

注:开始写这篇博文时候还是希望能对训练部分代码加一些详细的注释放上来,但是实际发现想多了……代码比较长,而且也没有必要一行一行注释。目前这部分代码基本上能够看懂,有一些细节还不是很清楚,实际用到的时候再作详细了解

附件:
blocks_setup_done.tar.gz

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注