Convolutional Neural Networks for Sentence Classification
遇到的最严重问题,优先列出:
新版本theano.tensor.signal包下已经不包含downsample模块,然后利用theano.tensor.signal.pool.pool_2d()方法代替了theano.tensor.signal.downsample.max_pool_2d()方法
实验
1.实验所需的是theano框架
安装稳定的最前沿版本:
|
|
2.gpuarray 的安装:为了利用gpu加速运行
1)下载安装包
|
|
2)安装
For libgpuarray
|
|
For pygpu:
|
|
If you installed libgpuarray in a path that isn’t a default one, you will need to specify where it is. Replace the first line by something like this:
|
|
If installed globally under Linux (in /usr/local), you might have to run:
|
|
虽然没爱搞懂,但最后一步我没有执行
实验数据:在这个页面我下载的是GoogleNews-vectors-negative300.bin.gz
这个压缩包解压缩后就是已经用word2vec预处理好的数据
然后就是根据这个例子做实验
Data Preprocessing
To process the raw data, run
|
|
where path points to the word2vec binary file (i.e. GoogleNews-vectors-negative300.bin
file). This will create a pickle object called mr.p
in the same folder, which contains the dataset in the right format.
Note: This will create the dataset with different fold-assignments than was used in the paper. You should still be getting a CV score of >81% with CNN-nonstatic model, though.
Running the models (CPU)
这一步会遇到一个很严重的问题就是前面说的新版本theano.tensor.signal包下已经不包含downsample模块,然后利用theano.tensor.signal.pool.pool_2d()方法代替了theano.tensor.signal.downsample.max_pool_2d()方法,所以需要修改conv_net_classes.py中相关的地方。
Example commands:
|
|
This will run the CNN-rand, CNN-static, and CNN-nonstatic models respectively in the paper.
Using the GPU
GPU will result in a good 10x to 20x speed-up, so it is highly recommended. To use the GPU, simply change device=cpu
to device=gpu
(or whichever gpu you are using). For example:
|
|
Example output
CPU output:
|
|
GPU output:
|
|
###