为了账号安全,请及时绑定邮箱和手机立即绑定

Keras假形状,

Keras假形状,

Go
呼啦一阵风 2021-09-11 20:36:10
有人知道keras吗?我无法理解问题是什么?我遇到了这个问题:ValueError: You are passing a target array of shape (1000, 1) while using as loss `categorical_crossentropy`. `categorical_crossentropy` expects targets to be binary matrices (1s and 0s) of shape (samples, classes). If your targets are integer classes, you can convert them to the expected format via...from keras.utils import to_categoricaly_binary = to_categorical(y_int)Alternatively, you can use the loss function ` sparse_categorical_crossentropy` instead, which does expect integer targets.Hieer是完整代码:https ://ideone.com/v9yojt
查看完整描述

1 回答

?
当年话下

TA贡献1890条经验 获得超9个赞

改变categorical_crossentropybinary_crossentropy

在第 83 行中设置:

model.compile(loss='binary_crossentropy', optimizer="sgd", metrics=['accuracy'])


查看完整回答
反对 回复 2021-09-11
  • 1 回答
  • 0 关注
  • 683 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号