
nlp
文章平均质量分 68
小涵涵
这个作者很懒,什么都没留下…
展开
-
NLP data处理
NLP data处理pytorch datasettorchtextiterator加载词向量 主要总结一下,NLP数据的处理过程 NLP数据的处理主要有分词,然后记录每个词出现的次数,每个词对应的id,word2id,id2word。python有很多库如from collections import Counter,scipy,jieba等配合使用 pytorch dataset file = open('train.txt','r') i = 0 data,tag,sentence_lst = []原创 2021-10-27 10:47:49 · 798 阅读 · 0 评论 -
nlp fasttext
fasttextn-gram实现model fasttext用于词向量和文本分类,使用词袋以及n-gram袋表征语句 n-gram实现 def biGramHash(sequence, t, buckets): t1 = sequence[t - 1] if t - 1 >= 0 else 0 return (t1 * 14918087) % buckets def triGramHash(sequence, t, buckets):原创 2021-09-15 18:52:11 · 311 阅读 · 0 评论 -
NLP词向量
NLP分词Word2vec数据预处理skip-gramCBOW 分词 Word2vec Word2vec分为skip-gram和CBOW(continuous bag of words),前者是通过中心词预测窗口词,后者是通过窗口预测中心词。 数据预处理 K = 10 # 负样本随机采样数量 C = 3 # 周围单词的数量 NUM_EPOCHS = 2 VOCAB_SIZE = 30000 BATCH_SIZE = 128 LEARNING_RATE原创 2021-09-15 14:07:58 · 354 阅读 · 0 评论