解决ValueError: Error when checking target: expected dense_15 to have shape (None, 6) but got array with shape (112, 3)
报错代码
model_val = Sequential()
model_val.fit(x_train,y_train,epochs=50,shuffle=True,validation_data=(x_test,y_test))
报错日志
ValueError: Error when checking target: expected dense_15 to have shape (None, 6) but got array with shape (112, 3)
报错原因
模型结构存在问题。现在的输出(None, 6)有错, 应该为(112, 3)
解决办法
# 增加一个输出层与(112, 3)匹配
model_val.add(Dense(3,activation='softmax'))
欢迎大家交流学习,任何问题都可以留言