码迷,mamicode.com
首页 > 其他好文 > 详细

ValueError: Error when checking input: expected conv2d_1_input to have 4 dimensions, but got array with shape (60000, 28, 28)

时间:2019-07-11 12:36:04      阅读:776      评论:0      收藏:0      [点我收藏+]

标签:exception   stand   error   cte   call   mode   网络   ror   charm   

  • 报错
Traceback (most recent call last):
  File "D:/PyCharm 5.0.3/WorkSpace/3.Keras/3.构建各种神经网络/3.CNN.py", line 46, in <module>
    model.fit(x_train, y_train, epochs=1, batch_size=32)
  File "D:\Anaconda3\lib\site-packages\keras\engine\training.py", line 952, in fit
    batch_size=batch_size)
  File "D:\Anaconda3\lib\site-packages\keras\engine\training.py", line 751, in _standardize_user_data
    exception_prefix='input')
  File "D:\Anaconda3\lib\site-packages\keras\engine\training_utils.py", line 128, in standardize_input_data
    'with shape ' + str(data_shape))
ValueError: Error when checking input: expected conv2d_1_input to have 4 dimensions, but got array with shape (60000, 28, 28)
  • 原因
    输入的格式不对
  • 解决
    将数据集标准化
x_train = x_train.reshape(x_train.shape[0],1,28,28)/255
x_test = x_test.reshape(x_test.shape[0],1,28,28)/255
y_train = np_utils.to_categorical(y_train,num_classes=10)
y_test = np_utils.to_categorical(y_test,num_classes=10)

ValueError: Error when checking input: expected conv2d_1_input to have 4 dimensions, but got array with shape (60000, 28, 28)

标签:exception   stand   error   cte   call   mode   网络   ror   charm   

原文地址:https://www.cnblogs.com/peng8098/p/11169059.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!