from gensim.models.doc2vec import Doc2Vec, TaggedDocument
from random import shuffle
import logging
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
tagged_data = []
clas = ['type1', 'type2', 'type3']
for cla in clas:
with open(f'../data/jieba/{cla}train.txt', 'r', encoding='UTF-8')as f:
i = 0
lines = f.readlines()
for line in lines:
tagged_data.append(TaggedDocument(words=line.split(' ')[:-1], tags=[cla + str(i)]))
i += 1
num_doc = len(tagged_data)
shuffle(tagged_data)
model = Doc2Vec(dm=1, vector_size=128, window=5, alpha=0.01, min_alpha=0.0001, max_vocab_size=100000, sample=1e-5, workers=4, epochs=3, hs=1, dm_mean=1)
model.build_vocab(tagged_data)
model.train(documents=tagged_data, epochs=model.epochs, total_examples=num_doc)
model.save("d2v.model")
Выше приведен мой код, а вывод выглядит как
2019-05-11 01:11:48,177 : INFO : EPOCH 1 - PROGRESS: at 3.64% examples, 307751 words/s, in_qsize 7, out_qsize 0
2019-05-11 01:11:49,195 : INFO : EPOCH 1 - PROGRESS: at 7.63% examples, 316010 words/s, in_qsize 7, out_qsize 0
2019-05-11 01:11:50,196 : INFO : EPOCH 1 - PROGRESS: at 11.44% examples, 316465 words/s, in_qsize 8, out_qsize 0
Как получить значение функции потерь на каждом шаге, чтобы я мог ее визуализировать?