亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

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 關注
  • 645 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號