本文目录一览:

word2vec Out of dictionary word,为什么

可能是你的word的版本比较高,里面的公式编辑器国外的pdf软件不带中文的插件导致。可以考虑用单下载公式编辑器,或者将你的转换成图片插入也行。

如何开启深度学习之旅

如何开启深度学习之旅?这三大类125篇论文为你导航(附资源下载) 

如果你现在还是个深度学习的新手,那么你问的第一个问题可能是「我应该从哪篇文章开始读呢?在 G上,s准备了一套深度学习阅读清单,而且这份清单在随时更新。

项目地址:

这份清单依照下述 4 条原则建立:

从整体轮廓到细节

从过去到当代

从一般到具体领域

聚焦当下最先进技术

你会发现很多非常新但很值得一读的论文。这份清单我会持续更新。

1、深度学习的历史与基础知识

1.0 书籍

[0] Bengio, Yoshua, Ian J. Goodfellow, and Aaron Courville. 深度学习(Deep learning), An MIT Press book. (2015). (这是深度学习领域的圣经,你可以在读此书的同时阅读下面的论文)。

1.1 调查类:

[1] LeCun, Yann, Yoshua Bengio, and Geoffrey Hinton. 深度学习 (Deep learning), Nature 521.7553 (2015): 436-444. (深度学习三位大牛对各种学习模型的评价)

1.2 深度信念网络(DBN)(深度学习前夜的里程碑)

[2] Hinton, Geoffrey E., Simon Osindero, and Yee-Whye Teh. 一个关于深度信念网络的快速学习算法(A fast learning algorithm for deep belief nets), (深度学习的前夜)

[3] Hinton, Geoffrey E., and Ruslan R. Salakhutdinov. 使用神经网络降低数据的维度(Reducing the dimensionality of data with neural networks), (里程碑式的论文,展示了深度学习的可靠性)

1.3 ImageNet 的演化(深度学习从这里开始)

[4] Krizhevsky, Alex, Ilya Sutskever, and Geoffrey E. Hinton. 使用深度卷积神经网络进行 ImageNet 分类任务(Imagenet classification with deep convolutional neural networks)(AlexNet, 深度学习的突破)

[5] Simonyan, Karen, and Andrew Zisserman. 针对大尺度图像识别工作的的超深卷积网络(Very deep convolutional networks for large-scale image recognition) (VGGNet, 神经网络开始变得非常深!)

[6] Szegedy, Christian, et al. 更深的卷积(Going deeper with convolutions)(GoogLeNet)

[7] He, Kaiming, et al. 图像识别的深度残差学习(Deep residual learning for image recognition)(ResNet,超级超级深的深度网络!CVPR--IEEE 国际计算机视觉与模式识别会议-- 最佳论文)

1.4 语音识别的演化

[8] Hinton, Geoffrey, et al. 语音识别中深度神经网络的声学建模(Deep neural networks for acoustic modeling in speech recognition: The shared views of four research groups)(语音识别中的突破)

[9] Graves, Alex, Abdel-rahman Mohamed, and Geoffrey Hinton. 用深度循环神经网络进行语音识别(Speech recognition with deep recurrent neural networks)(RNN)

[10] Graves, Alex, and Navdeep Jaitly. 面向端到端语音识别的循环神经网络(Towards End-To-End Speech Recognition with Recurrent Neural Networks)

[11] Sak, Ha?im, et al. 语音识别中快且精准的循环神经网络声学模型(Fast and accurate recurrent neural network acoustic models for speech recognition)(语音识别系统)

[12] Amodei, Dario, et al. Deep speech 2:英语和汉语的端到端语音识别(Deep speech 2: End-to-end speech recognition in english and mandarin)(百度语音识别系统)

[13] W. Xiong, J. Droppo, X. Huang, F. Seide, M. Seltzer, A. Stolcke, D. Yu, G. Zweig,在对话语音识别中实现人类平等(Achieving Human Parity in Conversational Speech Recognition)

当你读完了上面给出的论文,你会对深度学习历史有一个基本的了解,深度学习建模的基本架构(包括了 CNN,RNN,LSTM)以及深度学习如何可以被应用于图像和语音识别问题。下面的论文会让你对深度学习方法,不同应用领域中的深度学习技术和其局限有深度认识。

2 深度学习方法

2.1 模型

[14] Hinton, Geoffrey E., et al. 通过避免特征检测器的共适应来改善神经网络(Improving neural networks by preventing co-adaptation of feature detectors)(Dropout)

[15] Srivastava, Nitish, et al. Dropout:一种避免神经网络过度拟合的简单方法(Dropout: a simple way to prevent neural networks from overfitting)

[16] Ioffe, Sergey, and Christian Szegedy. Batch normalization:通过减少内部协变量加速深度网络训练(Batch normalization: Accelerating deep network training by reducing internal covariate shift)(2015 年一篇杰出论文)

[17] Ba, Jimmy Lei, Jamie Ryan Kiros, and Geoffrey E. Hinton.层归一化(Layer normalization)(批归一化的升级版)

[18] Courbariaux, Matthieu, et al. 二值神经网络:训练神经网络的权重和激活约束到正 1 或者负 1(Binarized Neural Networks: Training Neural Networks with Weights and Activations Constrained to+ 1 or?1)(新模型,快)

[19] Jaderberg, Max, et al. 使用合成梯度的解耦神经接口(Decoupled neural interfaces using synthetic gradients)(训练方法的发明,令人惊叹的文章)

[20] Chen, Tianqi, Ian Goodfellow, and Jonathon Shlens. Net2net:通过知识迁移加速学习(Net2net: Accelerating learning via knowledge transfer) (修改之前的训练网络以减少训练)

[21] Wei, Tao, et al. 网络形态(Network Morphism)(修改之前的训练网络以减少训练 epoch)

2.2 优化

[22] Sutskever, Ilya, et al. 有关深度学习中初始化与动量因子的研究(On the importance of initialization and momentum in deep learning) (动量因子优化器)

[23] Kingma, Diederik, and Jimmy Ba. Adam:随机优化的一种方法(Adam: A method for stochastic optimization)(可能是现在用的最多的一种方法)

[24] Andrychowicz, Marcin, et al. 通过梯度下降学习梯度下降(Learning to learn by gradient descent by gradient descent) (神经优化器,令人称奇的工作)

[25] Han, Song, Huizi Mao, and William J. Dally. 深度压缩:通过剪枝、量子化训练和霍夫曼代码压缩深度神经网络(Deep compression: Compressing deep neural network with pruning, trained quantization and huffman coding) (ICLR 最佳论文,来自 DeePhi 科技初创公司,加速 NN 运行的新方向)

[26] Iandola, Forrest N., et al. SqueezeNet:带有 50x 更少参数和小于 1MB 模型大小的 AlexNet-层级精确度(SqueezeNet: AlexNet-level accuracy with 50x fewer parameters and 1MB model size.) (优化 NN 的另一个新方向,来自 DeePhi 科技初创公司)

2.3 无监督学习/深度生成模型

[27] Le, Quoc V. 通过大规模无监督学习构建高级特征(Building high-level features using large scale unsupervised learning.) (里程碑,吴恩达,谷歌大脑,猫)

[28] Kingma, Diederik P., and Max Welling. 自动编码变异贝叶斯(Auto-encoding variational bayes.) (VAE)

[29] Goodfellow, Ian, et al. 生成对抗网络(Generative adversarial nets.)(GAN, 超酷的想法)

[30] Radford, Alec, Luke Metz, and Soumith Chintala. 带有深度卷曲生成对抗网络的无监督特征学习(Unsupervised representation learning with deep convolutional generative adversarial networks.)(DCGAN)

[31] Gregor, Karol, et al. DRAW:一个用于图像生成的循环神经网络(DRAW: A recurrent neural network for image generation.) (值得注意的 VAE,杰出的工作)

[32] Oord, Aaron van den, Nal Kalchbrenner, and Koray Kavukcuoglu. 像素循环神经网络(Pixel recurrent neural networks.)(像素 RNN)

[33] Oord, Aaron van den, et al. 使用像素 CNN 解码器有条件地生成图像(Conditional image generation with PixelCNN decoders.) (像素 CNN)

2.4 RNN/序列到序列模型

[34] Graves, Alex. 带有循环神经网络的生成序列(Generating sequences with recurrent neural networks.)(LSTM, 非常好的生成结果,展示了 RNN 的力量)

[35] Cho, Kyunghyun, et al. 使用 RNN 编码器-解码器学习词组表征用于统计机器翻译(Learning phrase representations using RNN encoder-decoder for statistical machine translation.) (第一个序列到序列论文)

[36] Sutskever, Ilya, Oriol Vinyals, and Quoc V. Le. 运用神经网路的序列到序列学习(Sequence to sequence learning with neural networks.」)(杰出的工作)

[37] Bahdanau, Dzmitry, KyungHyun Cho, and Yoshua Bengio. 通过共同学习来匹配和翻译神经机器翻译(Neural Machine Translation by Jointly Learning to Align and Translate.)

[38] Vinyals, Oriol, and Quoc Le. 一个神经对话模型(A neural conversational model.)(聊天机器人上的序列到序列)

2.5 神经图灵机

[39] Graves, Alex, Greg Wayne, and Ivo Danihelka. 神经图灵机器(Neural turing machines.)arXiv preprint arXiv:1410.5401 (2014). (未来计算机的基本原型)

[40] Zaremba, Wojciech, and Ilya Sutskever. 强化学习神经图灵机(Reinforcement learning neural Turing machines.)

[41] Weston, Jason, Sumit Chopra, and Antoine Bordes. 记忆网络(Memory networks.)

[42] Sukhbaatar, Sainbayar, Jason Weston, and Rob Fergus. 端到端记忆网络(End-to-end memory networks.)

[43] Vinyals, Oriol, Meire Fortunato, and Navdeep Jaitly. 指示器网络(Pointer networks.)

[44] Graves, Alex, et al. 使用带有动力外部内存的神经网络的混合计算(Hybrid computing using a neural network with dynamic external memory.)(里程碑,结合上述论文的思想)

2.6 深度强化学习

[45] Mnih, Volodymyr, et al. 使用深度强化学习玩 atari 游戏(Playing atari with deep reinforcement learning.) (第一篇以深度强化学习命名的论文)

[46] Mnih, Volodymyr, et al. 通过深度强化学习达到人类水准的控制(Human-level control through deep reinforcement learning.) (里程碑)

[47] Wang, Ziyu, Nando de Freitas, and Marc Lanctot. 用于深度强化学习的决斗网络架构(Dueling network architectures for deep reinforcement learning.) (ICLR 最佳论文,伟大的想法 )

[48] Mnih, Volodymyr, et al. 用于深度强化学习的异步方法(Asynchronous methods for deep reinforcement learning.) (当前最先进的方法)

[49] Lillicrap, Timothy P., et al. 运用深度强化学习进行持续控制(Continuous control with deep reinforcement learning.) (DDPG)

[50] Gu, Shixiang, et al. 带有模型加速的持续深层 Q-学习(Continuous Deep Q-Learning with Model-based Acceleration.)

[51] Schulman, John, et al. 信赖域策略优化(Trust region policy optimization.) (TRPO)

[52] Silver, David, et al. 使用深度神经网络和树搜索掌握围棋游戏(Mastering the game of Go with deep neural networks and tree search.) (阿尔法狗)

2.7 深度迁移学习/终身学习/尤其对于 RL

[53] Bengio, Yoshua. 表征无监督和迁移学习的深度学习(Deep Learning of Representations for Unsupervised and Transfer Learning.) (一个教程)

[54] Silver, Daniel L., Qiang Yang, and Lianghao Li. 终身机器学习系统:超越学习算法(Lifelong Machine Learning Systems: Beyond Learning Algorithms.) (一个关于终生学习的简要讨论)

[55] Hinton, Geoffrey, Oriol Vinyals, and Jeff Dean. 提取神经网络中的知识(Distilling the knowledge in a neural network.) (教父的工作)

[56] Rusu, Andrei A., et al. 策略提取(Policy distillation.) (RL 领域)

[57] Parisotto, Emilio, Jimmy Lei Ba, and Ruslan Salakhutdinov. 演员模仿:深度多任务和迁移强化学习(Actor-mimic: Deep multitask and transfer reinforcement learning.) (RL 领域)

[58] Rusu, Andrei A., et al. 渐进神经网络(Progressive neural networks.)(杰出的工作,一项全新的工作)

2.8 一次性深度学习

[59] Lake, Brenden M., Ruslan Salakhutdinov, and Joshua B. Tenenbaum. 通过概率程序归纳达到人类水准的概念学习(Human-level concept learning through probabilistic program induction.)(不是深度学习,但是值得阅读)

[60] Koch, Gregory, Richard Zemel, and Ruslan Salakhutdinov. 用于一次图像识别的孪生神经网络(Siamese Neural Networks for One-shot Image Recognition.)

[61] Santoro, Adam, et al. 用记忆增强神经网络进行一次性学习(One-shot Learning with Memory-Augmented Neural Networks ) (一个一次性学习的基本步骤)

[62] Vinyals, Oriol, et al. 用于一次性学习的匹配网络(Matching Networks for One Shot Learning.)

[63] Hariharan, Bharath, and Ross Girshick. 少量视觉物体识别(Low-shot visual object recognition.)(走向大数据的一步)

3 应用

3.1 NLP(自然语言处理)

[1] Antoine Bordes, et al. 开放文本语义分析的词和意义表征的联合学习(Joint Learning of Words and Meaning Representations for Open-Text Semantic Parsing.)

[2] Mikolov, et al. 词和短语及其组合性的分布式表征(Distributed representations of words and phrases and their compositionality.) (word2vec)

[3] Sutskever, et al. 运用神经网络的序列到序列学习(Sequence to sequence learning with neural networks.)

[4] Ankit Kumar, et al. 问我一切:动态记忆网络用于自然语言处理(Ask Me Anything: Dynamic Memory Networks for Natural Language Processing.)

[5] Yoon Kim, et al. 角色意识的神经语言模型(Character-Aware Neural Language Models.)

[6] Jason Weston, et al. 走向人工智能-完成问题回答:一组前提玩具任务(Towards AI-Complete Question Answering: A Set of Prerequisite Toy Tasks.) (bAbI 任务)

[7] Karl Moritz Hermann, et al. 教机器阅读和理解(Teaching Machines to Read and Comprehend.)(CNN/每日邮件完形风格问题)

[8] Alexis Conneau, et al. 非常深度卷曲网络用于自然语言处理(Very Deep Convolutional Networks for Natural Language Processing.) (在文本分类中当前最好的)

[9] Armand Joulin, et al. 诡计包用于有效文本分类(Bag of Tricks for Efficient Text Classification.)(比最好的差一点,但快很多)

如何在windows下使用word2vec

可能是你的word的版本比较高,里面的公式编辑器国外的pdf软件不带中文的插件导致。可以考虑用单下载公式编辑器,或者将你的转换成图片插入也行。

嵌着属于什么词性和?

原文来源:DATASCIENCE

作者:Ruslana Dalinina

「机器人圈」编译:嗯~阿童木呀、多啦A亮

「机器人圈」正式更名为「雷克世界」,后台回复「雷克世界」查看更多详情。

介绍

相信大家都清楚,自然语言处理(NLP)所涉及的广阔领域使得我们能够理解从在线评论到音频录制这样大量语言数据的模式。但在数据科学家真正挖掘出一个NLP问题之前,他或她必须为此奠定基础,从而帮助模型对即将遇到的不同语言单位有所了解。

词嵌入(Word embeddings)是一组广泛应用于预测NLP建模的特征工程技术,特别是在深度学习应用中的使用更为显著。词嵌入是将词的稀疏向量表示转换为密集、连续的向量空间,使你能够识别单词和短语之间的相似性,而这一点很大程度上依赖于它们的语境。

在本文中,我将详细阐述一下词嵌入背后的原理,并演示如何使用这些技术对来自亚马逊的500000份评论数据创建相似词汇的集群。你可以下载数据集()来进行追踪。

词嵌入:它们是如何运作的?

在典型的词袋(bag-of-words)模型中,每个单词都被认为是一个唯一的标记,与其他单词毫无关联。例如,即使“salt(盐)”和“seasoning(调味料)”平时都是高频地出现在相同的语境或是句子中,也将被分配一个唯一的ID。词嵌入是一系列特征工程技术,它将稀疏的词向量映射到基于周围语境的连续空间中。话句话说,你可以将此过程视为将高维向量词表示嵌入到一个较低维的空间中。

而这样的向量表示比较单词或短语提供了便利属性。例如,如果“salt”和“seasoning”出现在相同的语境中,那么模型将表明“salt”在概念上更接近于“seasoning”,而不是“chair(椅子)”。

现如今有几种用于构建词嵌入表示的模型。谷歌的word2vec是最为广泛使用的实现之一,而这主要得益于它的训练速度和性能。Word2vec是一个预测模型,这意味着它并不是像LDA(latent Dirichlet allocation)那样需要进行单词计数,而是被训练为从邻近词的语境中预测目标词。该模型首先使用独热编码(one-hot-encoding)对每个单词进行编码,然后使用权重矩阵将其馈送到隐藏层;该过程的输出则是目标单词。词嵌入向量实际上是该拟合模型的权重。为了更好地进行说明,这里有一个简单的视觉图:

实际上,Word2vec有两种“风格”的词嵌入模型:连续的词袋(CBOW)和跳格式。CBOW实现会在目标单词周围出现一个滑动窗口,以便于做出预测。而另一方面,跳格式模型则是截然相反的——它会预测出给定目标单词的语境周边的单词。有关跳格式模型的更多信息,请查阅此篇学术论文()。

入门

为什么有那么多人对词嵌入如此感兴趣呢?这主要是因为词嵌入在深度学习的多种任务中有着非常广泛的应用,如情绪分析、语法分析、命名称识别等。除此之外,它们还可以用于:

通过基于语境的保存单词与单词之间的相似性,提供一种更为复杂的方法来表示数字空间中的单词。

提供单词或短语之间的相似度的衡量标准。

用作分类任务中的特征。

提高模型性能。

使用词嵌入可以发现许多有趣的关系,最著名的例子莫过于此了:king - man + woman = queen。所以,请继续在Amazon Fine Foods评论数据集中进行词嵌入操作吧!

可以先从越多语料库开始,我将使用一个面向DataScience.com客户的模块,该模块被称之为“客户手册”,其中包含常见文本处理和建模任务的代码,例如删除或阻止不良字符。它也可以用于主题建模和意见挖掘任务。

# imports

%matplotlib inline

import os

import pandas as pd

import numpy

import matplotlib.pyplot as plt

import string

import re

from gensim import corpora

from gensim.models import Phrases

from nltk.corpus import stopwords

from nltk.stem.porter import PorterStemmer

from ds_voc.text_processing import TextProcessing

# sample for speed

raw_df = raw_df.sample(frac=0.1, replace=False)

print raw_df.shape

# grab review text

raw = list(raw_df['Text'])

print len(raw)

先标注我们的样本,并做一般的清理步骤:删除不好的字符,过滤单词和干扰:

# word2vec expexts a list of list: each document is a list of tokens

te = TextProcessing()

cleaned = [te.default_clean(d) for d in raw]

sentences = [te.stop_and_stem(c) for c in cleaned]

现在我们已经准备好适应一个模型了。这里我们使用gensim实现:

from gensim.models import Word2Vec

model = Word2Vec(sentences=sentences, # tokenized senteces, list of list of strings

size=300, # size of embedding vectors

workers=4, # how many threads?

min_count=20, # minimum frequency per token, filtering rare words

sample=0.05, # weight of downsampling common words

sg = 0, # should we use skip-gram? if 0, then cbow

iter=5,

hs = 0

)

X = model[model.wv.vocab]

瞧!这很简单。现在,你可以问这个模型有什么问题?回想一下,在相似情景下发生的词将被认为是相似的,从而形成“集群”。 从简单的例子开始,通过检查模型认为类似于“花生”的什么样的词语:

print (model.most_similar('peanut'))

[(u'butter', 0.9887357950210571), (u'fruit', 0.9589880108833313), (u'crunchi', 0.9448184967041016), (u'potato', 0.9327490329742432), (u'textur', 0.9302218556404114), (u'nut', 0.9176014065742493), (u'tasti', 0.9175000190734863), (u'sweet', 0.9135239124298096), (u'appl', 0.9122942686080933), (u'soft', 0.9103059768676758)]

不错,最相似的标记当然是“黄油”,其他的标记也很直观。然而,“水果”和“苹果”可能是客户提到果酱和花生酱时扩展的结果。让我们再举几个例子:

print (model.most_similar('coffee'))

[(u'k', 0.8691866397857666), (u'starbuck', 0.862629771232605), (u'keurig', 0.85813969373703), (u'decaf', 0.8456668853759766), (u'blend', 0.840221643447876), (u'bold', 0.8374124765396118), (u'cup', 0.8330360651016235), (u'brew', 0.8262926340103149), (u'espresso', 0.8225802183151245), (u'roast', 0.812541127204895)]

print (model.most_similar('spice'))

[(u'refresh', 0.9925233721733093), (u'caramel', 0.9756978750228882), (u'pepper', 0.9739495515823364), (u'cherri', 0.9737452268600464), (u'slightli', 0.9729464054107666), (u'cinnamon', 0.9727376699447632), (u'lemon', 0.9724155068397522), (u'blueberri', 0.9717040061950684), (u'sour', 0.971449613571167), (u'cocoa', 0.9712052345275879)]

请注意,即使“焦糖苹果香料”是一个受欢迎的组合,但与“香料”最相似的词语是“刷新”和“焦糖”。你可以扩展类比,不仅可以在上下文中包含多个词,还可以排除某些词。我对富含蛋白质的零食很感兴趣,但我不想服用蛋白质补充剂:

print (model.most_similar(['snack', 'protein'], negative=['supplement']))

这是模型得出来的结果:

[(u'chip', 0.7655218839645386), (u'bar', 0.7496042251586914), (u'potato', 0.7473998069763184), (u'peanut', 0.741823136806488), (u'feel', 0.7318717241287231), (u'cereal', 0.7217452526092529), (u'nut', 0.716484546661377), (u'butter', 0.7104200124740601), (u'healthi', 0.7084594964981079), (u'low', 0.7055443525314331)]

该模型发现,“薯条”,“酒吧”,“花生”,“坚果”和“健康”等词汇与“零食”和“蛋白质”相同处在同一词群中,但与“补充品”的词群不同。

当然,这些都是简单的例子,但别忘了我们在一个小样本的评论中训练了该模型。我建议你扩展数据集,以构建更强大的词嵌入。

可视化词向量

为了可视化所得到的单词嵌入,我们可以使用降维技术t-SNE,它可以将所得到的嵌入向量投影到二维中:

# visualize food data

from sklearn.manifold import TSNE

tsne = TSNE(n_components=2)

X_tsne = tsne.fit_transform(X)

plt.rcParams['figure.figsize'] = [10, 10]

plt.scatter(X_tsne[:, 0], X_tsne[:, 1])

plt.show()

我们可以看到一些集群形成。我们来标记每一个点,看看所得到的集群。你还可以使用散景库(bokeh library)进行交互式绘图,以便进行缩放。

from bokeh.plotting import figure, show

from bokeh.io import push_notebook, output_notebook

from bokeh.models import ColumnDataSource, LabelSet

def interactive_tsne(text_labels, tsne_array):

'''makes an interactive scatter plot with text labels for each point'''

# define a dataframe to be used by bokeh context

bokeh_df = pd.DataFrame(tsne_array, text_labels, columns=['x','y'])

bokeh_df['text_labels'] = bokeh_df.index

# interactive controls to include to the plot

TOOLS="hover, zoom_in, zoom_out, box_zoom, undo, redo, reset, box_select"

p = figure(tools=TOOLS, plot_width=700, plot_height=700)

# define data source for the plot

source = ColumnDataSource(bokeh_df)

# scatter plot

p.scatter('x', 'y', source=source, fill_alpha=0.6,

fill_color="#8724B5",

line_color=None)

# text labels

labels = LabelSet(x='x', y='y', text='text_labels', y_offset=8,

text_font_size="8pt", text_color="#555555",

source=source, text_align='center')

p.add_layout(labels)

# show plot inline

output_notebook()

show(p)

其中一些更具直观的意义,如左下角包含decaf,bean和french的集群:

附加提示

我们还可以通过在模型中添加二进制和/或部分语音标签来改进词嵌入。在同一个单词可能具有多重含义的情况下,词性标注可能很有用。例如,seasoning可以是名词也可以是动词,并且根据词性的不同而具有不同的含义。

sent_w_pos = [nltk.pos_tag(d) for d in sentences]

sents = [[tup[0]+tup[1] for tup in d] for d in sent_w_pos]

model_pos = Word2Vec(sentences=sents,

size=300,

workers=4,

min_count=20,

sample=0.05,

sg = 0,

hs=0,

iter=5

)

X = model_pos[model_pos.wv.vocab]

我们还可以在我们的模型中添加二进制对象,以便将频繁的单词对分组:

bigrams = Phrases(sentences)

model = Word2Vec(sentences=bigrams[sentences],

size=300,

workers=4,

min_count=20,

sample=0.05,

sg = 0,

iter=5,

hs = 0

)

X = model[model.wv.vocab]

结论

现在,你对词嵌入有了一些基本的了解,并可以使用gensim中的word2vec生成向量。这个有用的技术应该在你的NLP工具箱中,因为它可以在各种建模任务中派上用场。欲了解更多信息,请看DataScience.com平台的演示,查看我们的客户手册,如客户手册的语音和建模资源