我面临着分类分类器的模型输入形状的问题
x y
[1,2,3] [0]
[2,3,5] [1]
[2,1,6] [2]
[1,2,3] [0]
[2,3,5] [0]
[2,1,6] [2]
然后我将y标签更改为分类
y
[1,0,0]
[0,1,0]
[0,0,1]
[1,0,0]
[1,0,0]
[0,0,1]
我的x_train形状是(6000,3)y_train形状是(6000,3)x_test形状是(2000,3)y_test形状是(2000,3)
我尝试了这个模型并获得了 Value 错误
model=sequential()
model.add(Dense(1, input_shape(3,), activation="softmax"))
model.compile(Adam(lr=0.5), 'categorical_crossentropy', metrics=['accuracy'])
model.fit(X_train,y_train,epochs=50, verbose=1)
Value error: Error when checking target: expected dense_1 to have shape(None,1) but got array with shape (6000,3)
我不明白这个错误 . 帮我解决这个问题
1 回答
您需要网络的输出层与输出类的数量相匹配 . 你可以这样做