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

  • 报错
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)

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

时间: 2024-10-08 18:41:42

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

ValueError: Error when checking input: expected input_1 to have 2 dimensions, but got array with shape (100, 100, 100, 3)

报错 Traceback (most recent call last): File "D:/PyCharm 5.0.3/WorkSpace/3.Keras/1.Sequential与Model模型.Keras基本结构功能/2_1.py", line 22, in <module> model.fit(data,labels,epochs=3) File "D:\Anaconda3\lib\site-packages\keras\engine\training.p

Internal error: (org.jdom.input.JDOMParseException) Error on line 1: 文件提前结束。

环境: maven idea tomcat 异常描述: maven clean ,install都没问题,就是点击启动tomcat,时就报错,错误信息如下: Internal error: (org.jdom.input.JDOMParseException) Error on line 1: 文件提前结束.org.jdom.input.JDOMParseException: Error on line 1: 文件提前结束. at org.jdom.input.SAXBuilder.build(

keras 报错 ValueError: Tensor conversion requested dtype int32 for Tensor with dtype float32: &#39;Tensor(&quot;embedding_1/random_uniform:0&quot;, shape=(5001, 128), dtype=float32)&#39;

在服务器上训练并保存模型,复制到本地之后load_model()报错: ValueError: Tensor conversion requested dtype int32 for Tensor with dtype float32: 'Tensor("embedding_1/random_uniform:0", shape=(5001, 128), dtype=float32)' 原因:服务器和本地的运行环境配置不同 查看本地keras版本: In [1]: import kera

Webservice调用服务端 Unmarshalling Error: unexpected element (Xxx). Expected elements are Xxx

使用Axis2调用CXF服务端Webservice方法时: 报错:Unmarshalling Error: unexpected element (uri:"http://ejb.fss.keyman.com", local:"xmldata"). Expected elements are <{}arg0> 详细信息如下: org.apache.axis2.AxisFault: Unmarshalling Error: unexpected eleme

[bug]Syntax error, unrecognized expression: input#ctl00$ContentPlaceHolder1$Pager_input

1.在ie10上浏览页面的时候,突然发现在使用Aspnetpager的页面会有一个bug. 2. 3.查了很多解决方案,最后将vs2013中, 将该勾取消,再次浏览,你会发现就正常了,虽然该功能很强大,但是并不是什么时候都需要. 4.什么是 Browser Link ? 这个 Browser Link 的功能就是通过一个脚本文件架起流程器和 Visual Studio IDE 之前的一个通信桥梁, 在启用 Browser Link 后, Visual Studio 会给网站注入一个 IHttpM

【caffe】Error parsing text-format NetParameter: ****:**:Expected string.

错误描述: prototxt中第****行,第**列缺少一个整型数或者标识符. 解决方法: 检查对应的prototxt文件,第****行,第**列是否遗漏相关信息. 我的文件是在代码新旧版本没对应好~ layer { type: "Accuracy" } layers{ type: ACCURACY }

ORA_ERROR大全

转自:http://blog.csdn.net/haiross/article/details/12839229 常见错误:-60 ORA00060: deadlock detected while waiting for resource 一般错误:  - 1 ORA00001: unique constraint (.) violated  -17 ORA00017: session requested to set trace event  -18 ORA00018: maximum nu

CNN 可视化示例

CNN 可视化示例For keras < v1 In [1]: import os os.environ['THEANO_FLAGS']='mode=FAST_RUN,device=gpu,floatX=float32' # This gives a 'perform' error in compile #os.environ['THEANO_FLAGS']='mode=FAST_COMPILE,device=gpu1,floatX=float32' #os.environ['THEANO_FL

intellij (org.jdom.input.JDOMParseException) Error on line 1: 前言中不允许有内容。

今天打开前几天做的一个项目,发现运行后竟然出现 Error:Internal error: (org.jdom.input.JDOMParseException) Error on line 1: 前言中不允许有内容.org.jdom.input.JDOMParseException: Error on line 1: 前言中不允许有内容. at org.jdom.input.SAXBuilder.build(SAXBuilder.java:533) at org.jdom.input.SAXB