代码拉取完成,页面将自动刷新
#coding:utf-8
import numpy as np
import pandas as pd
from gensim.models import word2vec
import logging
#读入数据
def load_data(path):
data = np.load(path)
return data
x_train = load_data('E:/NLP/chinese-w2v-sentiment/data/x_train_data.npy')
x_test = load_data('E:/NLP/chinese-w2v-sentiment/data/x_test_data.npy')
y_train = load_data('E:/NLP/chinese-w2v-sentiment/data/y_train_data.npy')
y_test = load_data('E:/NLP/chinese-w2v-sentiment/data/y_test_data.npy')
print(x_train[0])
# 打印日志
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
#训练模型
#model = word2vec.Word2Vec(x_train,sg=0,hs=1,min_count=1,window=5,size=300)
def model(data,model_path):
model = word2vec.Word2Vec(data,sg=0,hs=1,min_count=1,window=5,size=300)
model.save(model_path)
return model
#训练数据集
train_model = model(x_train,'E:/NLP/chinese-w2v-sentiment/train_model.model')
test_model = model(x_test,'E:/NLP/chinese-w2v-sentiment/test_model.model')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。