我在 nolearn 库中使用 NeuralNet 类来执行分类任务。这是代码:
layers0 = [('input', InputLayer),
('hidden', DenseLayer),
('output', DenseLayer)]
net0 = NeuralNet(layers=layers0,
input_shape=(None, 7),
hidden_num_units=7,
output_num_units=6,
output_nonlinearity=softmax,
update=nesterov_momentum,
update_learning_rate=0.1,
update_momentum=0.2,
train_split=TrainSplit(eval_size=0),
verbose=0,
max_epochs=200)
net0.fit(X, y)
predict = net0.predict(X_test)
print confusion_matrix(ids, predict)
print "accuracy: ", accuracy_score(ids, predict)
此代码训练 NeuralNet 并在测试集上对其进行测试。但是当我多次运行时,每次都会给出不同的结果。那么在给定参数、训练集和测试集的情况下,如何训练 NeuralNet 只给出一个结果呢?