赞
踩
Chinese Simplified and Traditional, 12-layer, 768-hidden, 12-heads, 110M parameters
依旧采用上一节中使用的ai挑战赛用户评论信息。对于自己使用的场景按照对应的格式处理好即可。例如这边样本格式如下(正文+标签):
(说明 此处用的标签含义是从-2~1 共4种代表不同的情感标签,是个4分类。为了便于处理,会将标签投影到1~4 data.others_overall_experience = data.others_overall_experience + 3)
将样本分成三个文件,且放置于同一个文件夹下:
样本打乱之后按照比例划分。新建一个preprocess.py
的文件用于数据预处理。
import os
from sklearn.model_selection import train_test_split
from sklearn.utils import shuffle
def train_valid_test_split(x_data, y_data, validation_size = 0.1, test_size = 0.1):
x_, x_test, y_, y_test = train_test_split(x_data, y_data, test_size=test_size)
valid_size = validation_size / (1.0 - test_size)
x_train, x_valid, y_train, y_valid = train_test_split(x_, y_, test_size=valid_size)
return x_train, x_valid, x_test, y_train, y_valid, y_test
pd_all = pd.read_csv("./sample.csv"))
pd_all = shuffle(pd_all)
x_data, y_data = pd_all.content, pd_all.others_overall_experience
x_train, x_valid, x_test, y_train, y_valid, y_test
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。