NLP 계산 문서 유사도 doc2vec
1908 단어 NLP
import gensim
outp1 = 'D:\python_noweightpathway\TIA\docmodel'
file = open(u'D:\python_noweightpathway\TIA\TIAxmmc.txt', encoding='utf-8')
# fileghdjid = open(u'D:\python_noweightpathway\TIA\TIA.txt', encoding='utf-8')
# ghdjids = []
# for ghdjid in fileghdjid:
# ghdjids.append(ghdjid)
# i = 0
# for line in file:
# LabeledSentence(words=line.split(), labels=['SENT_%s' % ghdjids[i]])
# i = i + 1
documents = gensim.models.doc2vec.TaggedLineDocument(file)
model = gensim.models.Doc2Vec(documents, size=100, window=8, min_count=100, workers=8)
model.save(outp1)
모델 읽기
import gensim
model=gensim.models.Doc2Vec.load("D:\python_noweightpathway\TIA\docmodel")
print(model.docvecs.most_similar(4))
print(model.docvecs.similarity(2,12))
문방향량은 사실 단어방향량의 모델과 같다. 단지 훈련할 때 문서 id도 하나의 단어로 훈련한다. 그러면 문서 id는 문서 아래의 모든 단어의 정보를 배워서 하나의 문방향량을 만들 수 있다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
记录一个失败的GAN 实验以及后续计划我的想法是:让generator能够根据label来生成对应的图片、比如label为1、生成1的图片、而不是随机作成. 为了实现这个目标、我给discriminator的输入做了些手脚. vanilla 모형리, D적输入是单纯的图片向量,...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.