该部分描述了推断 (Reasoning Patterns)和概率流 (Flow of Probabilistic Influence)的相关内容。
Probabilistic Graphical Models (2)
这篇文章,主要讲解贝叶斯网络概览性的内容。
贝叶斯网概览
贝叶斯网络是概率图模型中很重要的两种模型之一。基于贝叶斯公式构建起来的。
该例子来自 Daphne Koller 的公开课,同时推荐仔细学习该公开课。本系列文章也是跟着课程的内容前进的,原视频没有中文字幕,可以在不明白的地方翻阅本系列文章补充。再次感谢 Daphne Koller 教授和她的课程。
上图是我们整个学习中,最为常用的也很好理解的一个贝叶斯网络例子。
该图表达了五个不同的随机变量和他们之间的关系。描述了这样一件事:课程的难度(Difficulty)和一个学生的智商(Intelligence)会对他这门课的课程成绩有影响,同时他的智商也会影响到他的 SAT 分数。课程的成绩同时会影响到教授给他的推荐信。整个网络的架构很合理,跟符合人们生活的认知。比如课程难度没法直接影响教授的推荐信,只能通过课程成绩间接影响。
Probabilistic Graphical Models (1)
Object Detection - YOLO
Paper
code: Tensorflow, Caffe, Pytorch
YOLO 和 R-CNN 系列的 Object Detection 网络完全不同,采用了两种不同的思路。从 YOLO 的名字 You Only Look Once 就可以知道,原始的 R-CNN 系列是先得到 proposal 然后通过网络分类和回归。YOLO 则是直接在输出层回归 bounding box 的位置和目标的类别,该方法最大的特性就是快,可以达到实时检测,在 TITAN X 上可以达到 45 帧每秒,不过准确度显然是不如 R-CNN 系列的高了。
Object Detection - R-FCN
Paper
code: Python, MxNet, Pytorch
R-FCN 意在不降低太多准确率的同时,提高 R-CNN 系列网络的速度。该网络试图解决 ROIPooling 之后的单独卷积问题,从而大大提高了网络速度。
Object Detection - Faster R-CNN
Paper
code: Pytorch, Tensorflow
最近开始给学校的实验室写关于目标识别领域各大主要算法的综述,开一个长篇更新,今天简单说一说 Faster R-CNN。
Faster R-CNN 基于 Fast R-CNN 的基础上进行了相关改进,提高了运行的速度,同时提高了准确率。
Let's go, Pytorch
Recently, I am preparing for a ship detection competition and learning tensorflow at the same time. But I noticed that the code style of tensorflow is awful. I do not want to waste a lot of time to learn the tensorflow grammar even if I am a big Google fan. So I try to find some alternatives.
After reading a lot of introductions, I make a decision to learn Pytorch and use it as my major tools during my postgraduate period. Pytorch is so awesome.
I have tried to write a ConvAutoEncoder and I will introduce that how to make the autoencoder with Pytorch in this blog.
Python Memory Management
Last day,I tried to feed some test images to my trained model to test the performance of my model, But I have faced some low-level problem.
I use this code to read image and send it to the detection function:
1 | im = cv2.imread(im_file) |
Everything is ok when I test my model with a little of images. But if I test my model with more than 1000 images, the test program would crash. After that, I ran the test program again and watched the memory usage. I noticed that the memory usage became full after a few iteration. So I need to do something to collect the useless memory.
The solution is delete the image object when it is useless.
1 | del im |
But the memory of the useless image object will not be collected immediately unless I call the collect()
function of gc
module.
1 | gc.collect() |
If anything wrong, PLEASE tell me by e-mail or leave a message on this page.
Tensorflow FasterRCNN
最近在做 BDCI 的复杂气象条件的船只识别比赛,在 Tensorflow 上训练 Faster RCNN 的时候遇到了很奇怪的问题,折腾了一晚上终于解决了,具体表现为
loss 会在某次迭代的时候变为 Nan,Github 上有很多说什么调小学习率之类的,都没有解决我的问题,最后终于发现是代码和 xml 的问题。
首先代码中其在计算 xmin 等坐标的时候,都做了减一,那么当你的 xml 中有坐标是 0 的时候,就会减一变为 65536,那么就可能会出现下面这样的错误提示:1
RuntimeWarning: invalid value encountered in greater_equalkeep = np.where((ws >= min_size) & (hs >= min_size))[0]
Where is the vector in word2vec-CBOW?
本周看的一篇论文,Incremental Dual-memory LSTM in Land Cover Prediction 中有提到使用了 word2vec 中的 CBOW 模型,进行标签序列的向量化,从而将标签序列信息加入到 LSTM 中。为此去理解 word2vec 中的 CBOW 模型。
CBOW 模型是 word2vec 的一种,用来建立词语的向量表示。CBOW 模型的输入为一个句子,扣除了其中一个单词的剩余其他词汇。之后用这几个上下文的词汇对扣去的词汇进行预测。整体效果如图所示
可以发现,CBOW 模型,更像是用来根据上下文进行单词的推断。那么我们之前不是说 word2vec 是用来将单词转化为向量的么,为什么这里就变成了单词推断?