【问题标题】:when using CNN ,to_categorical()wrong [closed]使用 CNN 时,to_categorical() 错误 [关闭]
【发布时间】:2017-12-06 10:12:03
【问题描述】:

将 CNN 用于手写数字。

【问题讨论】:

  • 请将堆栈跟踪作为文本,而不是图像
  • 您需要提供更多详细信息

标签: deep-learning keras mnist


【解决方案1】:

没有任何代码很难提供帮助,但在 Keras > 2.0 中,to_categorial 的参数是 y 和 num_classes,但您似乎正在尝试传递 nb_classes。

更多详情请查看 api 文档。 https://keras.io/utils/#to_categorical

【讨论】:

  • X_train=X_train.reshape(-1,1,28,28) X_test=X_test.reshape(-1,1,28,28) y_train=np_utils.to_categorical(y_train,nb_classes=10) y_test=np.utils.to_categorical(y_test,nb_classes=10) 这是具体代码
  • 请尝试将关键字 nb_classes 替换为 num_classes。
  • 非常感谢。
猜你喜欢
  • 2018-04-10
  • 1970-01-01
  • 2018-12-20
  • 2021-07-05
  • 2018-07-02
  • 1970-01-01
  • 1970-01-01
  • 2020-11-07
  • 1970-01-01
相关资源
最近更新 更多