具有2个连续输出值的多层感知器回归器

时间:2018-11-29 18:45:37

标签: python neural-network mlp

我正在尝试构建一个神经网络以输出两个连续值。我尝试这样做与回答此问题类似:neural network with multiple outputs in sklearn

我尝试拟合模型,但是不断得到:

“ ValueError:设置具有序列的数组元素。”

这是我的代码:

reg = MLPRegressor(solver='lbfgs', alpha=1e-5,
               hidden_layer_sizes=(5, 2), random_state=1)
reg.fit(X_train, y_trainv)
print("Accuracy on the training subset: {:.3f}".format(reg.score(X_train,y_trainv)))
print("Accuracy on the test subset: {:.3f}".format(reg.score(X_test,y_testv)))

我觉得问题出在我的Y(y_trainvy_testv)上,但我尝试将其设置为与neural network with multiple outputs in sklearn中答案相同的格式,例如

y_trainv = [[2,5],...,[4,2]] ...

下面是y_trainv和dtypes的快速浏览:

                      both
94222   [1.0, 3.7511998254799344]
44960    [1.5, 4.547389855609031]
100535   [0.5, 2.181389581848419]
99910    [2.5, 3.941753323680401]
13734   [5.0, 1.6753846153846155]
34907    [3.0, 7.014474885844745]

y_trainv.dtypes
both    object
dtype: object

0 个答案:

没有答案