【发布时间】:2018-09-15 23:49:59
【问题描述】:
我面临分类分类器模型输入形状的问题
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 标签更改为 categorical as
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)
我试过这个模型并得到值错误
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)
我不明白这个错误。帮我解决这个问题
【问题讨论】: