Tutorials on training the Skip-thoughts vectors for features extraction of sentence.
Tutorials on training the Skip-thoughts vectors for features extraction of sentence.
1. Send emails and download the training dataset.
the dataset used in skip_thoughts vectors is from [BookCorpus]: http://yknzhu.wixsite.com/mbweb
first, you should send a email to the auther of this paper and ask for the link of this dataset. Then you will download the following files:

unzip these files in the current folders.
2. Open and download the tensorflow version code.
Do as the following links: https://github.com/tensorflow/models/tree/master/research/skip_thoughts
Then, you will see the processing as follows:
[Attention] when you install the bazel, you need to install this software, but do not update it. Or, it may shown you some errors in the following operations.
3. Install the packages needed.
- Bazel (instructions)
- TensorFlow (instructions)
- NumPy (instructions)
- scikit-learn (instructions)
- Natural Language Toolkit (NLTK)
- First install NLTK (instructions)
- Then install the NLTK data (instructions)
- gensim (instructions)
- Only required if you will be expanding your vocabulary with the word2vec model.
4. Encoding Sentences :
run the following py files.
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
import os.path
import scipy.spatial.distance as sd
from skip_thoughts import configuration
from skip_thoughts import encoder_manager
import pdb print("==>> Skip-Thought Vector ") # Set paths to the model.
VOCAB_FILE = "./skip_thoughts/pretrained/skip_thoughts_bi_2017_02_16/vocab.txt"
EMBEDDING_MATRIX_FILE = "./skip_thoughts/pretrained/skip_thoughts_bi_2017_02_16/embeddings.npy"
CHECKPOINT_PATH = "./skip_thoughts/model/train/model.ckpt-78581"
# The following directory should contain files rt-polarity.neg and rt-polarity.pos. # Set up the encoder. Here we are using a single unidirectional model.
# To use a bidirectional model as well, call load_model() again with
# configuration.model_config(bidirectional_encoder=True) and paths to the
# bidirectional model's files. The encoder will use the concatenation of
# all loaded models. print("==>> loading the pre-trained models ... ") encoder = encoder_manager.EncoderManager()
encoder.load_model(configuration.model_config(),
vocabulary_file=VOCAB_FILE,
embedding_matrix_file=EMBEDDING_MATRIX_FILE,
checkpoint_path=CHECKPOINT_PATH) print("==>> Done !") # Load the movie review dataset.
data = [' This is my second attempt to the tensorflow version skip_thought_vectors ... '] print("==>> the given sentence is: ", data) # Generate Skip-Thought Vectors for each sentence in the dataset.
encodings = encoder.encode(data) print("==>> the sentence feature is: ", encodings) ## the output feature is 2400 dimension.
wangxiao@AHU:/media/wangxiao/49cd8079-e619-4e4b-89b1-15c86afb5102/skip_thought_vector_onlineModels$ python run_sentence_feature_extraction.py
RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb
RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb
==>> Skip-Thought Vector
==>> loading the pre-trained models ...
WARNING:tensorflow:From ./skip_thoughts/skip_thoughts_model.py:360: create_global_step (from tensorflow.contrib.framework.python.ops.variables) is deprecated and will be removed in a future version.
Instructions for updating:
Please switch to tf.train.create_global_step
2018-05-13 21:36:27.670186: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
==>> Done !
==>> the given sentence is: [' This is my second attempt to the tensorflow version skip_thought_vectors ... ']
==>> the sentence feature is: [[-0.00676637 0.01928637 -0.01759908 ..., 0.00851333 0.00875245 -0.0040213 ]]
> ./run_sentence_feature_extraction.py(48)<module>()
-> print("==>> the encodings[0] is: ", encodings[0])
(Pdb) x = encodings[0]
(Pdb) x.size
2400
(Pdb)
as we can see from above terminal, the output feature vector is 2400-D.
...
Tutorials on training the Skip-thoughts vectors for features extraction of sentence.的更多相关文章
- Training Deep Neural Networks
http://handong1587.github.io/deep_learning/2015/10/09/training-dnn.html //转载于 Training Deep Neural ...
- Computer Vision Tutorials from Conferences (2) -- ECCV
ECCV 2012 (http://eccv2012.unifi.it/program/tutorials/) Vision Applications on Mobile using OpenCVGa ...
- awesome-nlp
awesome-nlp A curated list of resources dedicated to Natural Language Processing Maintainers - Keon ...
- [C3] Andrew Ng - Neural Networks and Deep Learning
About this Course If you want to break into cutting-edge AI, this course will help you do so. Deep l ...
- [C2P2] Andrew Ng - Machine Learning
##Linear Regression with One Variable Linear regression predicts a real-valued output based on an in ...
- pytorch做seq2seq注意力模型的翻译
以下是对pytorch 1.0版本 的seq2seq+注意力模型做法语--英语翻译的理解(这个代码在pytorch0.4上也可以正常跑): # -*- coding: utf-8 -*- " ...
- [C2P3] Andrew Ng - Machine Learning
##Advice for Applying Machine Learning Applying machine learning in practice is not always straightf ...
- 论文翻译——Recursive Deep Models for Semantic Compositionality Over a Sentiment Treebank
Abstract Semantic word spaces have been very useful but cannot express the meaning of longer phrases ...
- 第五章第四周习题: Transformers Architecture with TensorFlow
目录 Transformer Network Packages 1 - Positional Encoding 1.1 - Sine and Cosine Angles Exercise 1 - ge ...
随机推荐
- html5-select和datalist元素
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8&qu ...
- fzu2204 dp
2015-10-06 19:31:05 n个有标号的球围成一个圈.每个球有两种颜色可以选择黑或白染色.问有多少种方案使得没有出现连续白球7个或连续黑球7个. 每组包含n,表示球的个数.(1 <= ...
- jQuery事件--keypress([[data],fn])和trigger(type,[data])
keypress([[data],fn]) 概述 当键盘或按钮被按下时,发生 keypress 事件 keypress 事件与 keydown 事件类似.当按钮被按下时,会发生该事件.它发生在当前获得 ...
- Unicode字符需要几个字节来存储?
0)学习笔记: 我们常说的这句话“Unicode字符是2个字节”这句话有毛病 Unicode目前规划的总空间有17个平面, 0x0000---0x10FFFF,每个平面有 65536 个码点. Uni ...
- SQL 语法速记
----------------------------------DML(数据操作语言)---------------------------------- -- 一.INSERT VALUES语句 ...
- HTTPS实战之单向验证和双向验证
转载自:https://mp.weixin.qq.com/s/UiGEzXoCn3F66NRz_T9crA 原创: 涛哥 coding涛 6月9日 作者对https 解释的入目三分啊 (全文太长,太懒 ...
- multiple definition of qt_plugin_query_metadata
dustije 5 years ago I have a project with several plugins i want to compile into one library. I get ...
- github开源的一些ip解析 ,运营商信息,经纬度 地址 后续开发使用
https://github.com/wzhe06/ipdatabase ip解析 https://github.com/flyaction/ipdatabase 比较新 https://githu ...
- 搭建Vue2+Vuex+Webpack+Pug(jade)+Stylus环境
一.开发环境配置 开始之前,假设你已经安装了最新版本的 node 和 npm. 全局安装 vue-cli 和 webpack : npm install vue-cli webpack -g 创建工 ...
- WTL CHyperLink类的使用(超链接)
1.包含atlctrlx.h头文件: 2.声明一个CHyperLink类的变量: CHyperLink m_linkIntro; 3.在OnInitDialog函数里: m_linkIn ...