license:gpl region:us
---
license: gpl
---


#input_list：['hello','bag','hongkong','nike','dog']
#output_list：[0,1,0,0,0]


# 构建模型
class Classifier(nn.Module):
def __init__(self, input_dim, output_dim):
super(Classifier, self).__init__()
self.fc1 = nn.Linear(input_dim, 300)
self.relu1 = nn.ReLU()
self.fc2 = nn.Linear(300, 300)
self.relu1 = nn.ReLU()
self.fc3 = nn.Linear(300, 300)
self.relu1 = nn.ReLU()
self.fc4 = nn.Linear(300, output_dim)
self.softmax = nn.Softmax(dim=1)

def forward(self, x):
x = self.fc1(x)
x = self.relu1(x)
x = self.fc2(x)
x = self.relu1(x)
x = self.fc3(x)
x = self.relu1(x)
x = self.fc4(x)
x = self.softmax(x)
return x

input_dim = 300 # 输入特征的维度（关键词向量的维度）
output_dim = 2 # 二分类任务的类别数（符合要求为1，否则为0）


# 词向量生成需要加载预训练的Word2Vec模型
word2vec_model = KeyedVectors.load_word2vec_format('GoogleNews-vectors-negative300-SLIM.bin', binary=True)



