报错log为:

测试某条数据,结果为:
Traceback (most recent call last):
File “/home/appleyuchi/桌面/Python深度学习/deep_learning_chollet/第三章-神经网络入门/波士顿房价预测.py”, line 175, in
print"测试某条数据,结果为:",model.predict(test_data[0].reshape(13,1))
File “/home/appleyuchi/.virtualenvs/python2.7/local/lib/python2.7/site-packages/keras/engine/training.py”, line 1149, in predict
x, _, _ = self._standardize_user_data(x)
File “/home/appleyuchi/.virtualenvs/python2.7/local/lib/python2.7/site-packages/keras/engine/training.py”, line 751, in _standardize_user_data
exception_prefix=‘input’)
File “/home/appleyuchi/.virtualenvs/python2.7/local/lib/python2.7/site-packages/keras/engine/training_utils.py”, line 138, in standardize_input_data
str(data_shape))
ValueError: Error when checking input: expected dense_10_input to have shape (13,) but got array with shape (1,)
[Finished in 7.4s with exit code 1]
[shell_cmd: python -u “/home/appleyuchi/桌面/Python深度学习/deep_learning_chollet/第三章-神经网络入门/波士顿房价预测.py”]
[dir: /home/appleyuchi/桌面/Python深度学习/deep_learning_chollet/第三章-神经网络入门]
[path: /home/appleyuchi/bin:/home/appleyuchi/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin]

解决方案:

print"测试某条数据,结果为:",model.predict(test_data[0])

改成

print"测试某条数据,结果为:",model.predict(test_data[0].reshape(1,13))

神经网络需要的nxm其实是np.shape眼里的mxn
刚好反了一下。

expected dense_10_input to have shape (13,) but got array with shape (1,)相关推荐

  1. ValueError: Error when checking : expected input_1 to have 4 dimensions, but got array with shape (X

    ValueError: Error when checking : expected input_1 to have 4 dimensions, but got array with shape (5 ...

  2. memoryerror: Unable to allocate array with shape (60000, 28, 28) and data ty

    使用tf缩放图片遇到 (train_images, train_labels), (test_images,test_labels) = keras.datasets.fashion_mnist.lo ...

  3. SVM ValueError: y should be a 1d array, got an array of shape (1, 250) instead. Found input variable

    阅读前请看一下:我是一个热衷于记录的人,每次写博客会反复研读,尽量不断提升博客质量.文章设置为仅粉丝可见,是因为写博客确实花了不少精力.希望互相进步谢谢!! 文章目录 阅读前请看一下:我是一个热衷于记 ...

  4. np.array的shape的区别

    如下所示: 1 >>> import numpy as np 2 >>> x = np.array([1, 2]) 3 >>> y = np.ar ...

  5. ValueError: could not broadcast input array from shape (*,*) into shape (*)

    在将一个list转为np.array时出现如题错误. 错误原因: list中各元素的数据的shape不一致 解决办法: 1)方法1. 将list中的多个元素沿某个公共维度串联成一个张量,然后保存每个元 ...

  6. numpy数组array的shape属性-1维、2维···

    numpy数组array的shape属性-1维.2维··· numpy 创建的数组都有一个shape属性,它是一个元组,返回各个维度的维数.有时候我们可能需要知道某一维的特定维数. 一维情况 二维 可 ...

  7. Python Unable to allocate MiB for an array with shape

    最近在运行一个python项目,不过并不熟悉python,因为一直在做java开发的工作.最近改了一个python项目里的SQL,查询的数据量更大了,运行后抛出异常,所以初步怀疑是内存不够 pycha ...

  8. Unable to allocate xxx GiB for an array with shape (xxxx, xxxx)

    今天用Pycharm跑代码的时候报了个错误:Unable to allocate 14.1 GiB for an array with shape (xxxx, xxxx),主要是进行矩阵运算时涉及的 ...

  9. MemoryError: Unable to allocate 1.43 TiB for an array with shape (3700, 5300) and data type float64

    做图时遇到内存错误 MemoryError: Unable to allocate 1.43 TiB for an array with shape (3700, 5300) and data typ ...

最新文章

  1. Could not create the view: An unexpected exception was thrown. Myeclipse空间报错
  2. 在xcode调试断点不能停在代码区的终极解决方案
  3. 设备树的具体使用方法
  4. 计算机编程结构类型,运城计算机编程内存的概念与结构类型
  5. MQTT——QoS服务质量等级
  6. 以经济周期的角度来看世界
  7. 计算机组成原理的基础知识,计算机组成原理:基础知识部分习题解答(学习笔记)...
  8. Java中JDBC进阶教程之数据库的隔离级别!
  9. 浅议组播(一文看懂组播)
  10. Sass 基本特性-基础 笔记
  11. 中国诚信全球垫底?讲讲《Science》现在的论文有多不靠谱
  12. selnium 判断页面加载完成_Selenium 的页面加载以及几种等待的问题
  13. 利用手机设置路由器密码
  14. PYTHON混淆器 pyobfuscate
  15. 【图形图像处理】之栅格化介绍
  16. mac上如何彻底删除软件
  17. 前置++与后置++、前置--与后置--
  18. 强迫症患者之黑苹果优化(启动画面、CPU重命名、显示真实主板、开启12代CPU全核心)
  19. forward(转发)和redirect(重定向)有什么区别
  20. 华中科技大学2021计算机学院,2021年华中科技大学计算机考研科目

热门文章

  1. Repeater使用小结
  2. php笔记之echo/print比较
  3. cmd下pip安装mysql_pip安装MySQLpython
  4. git 如何把master分支代码合并到自己的分支
  5. java i o中文版_Java文件I/O的三种方法
  6. JQuery中.css()与.addClass()设置样式的区别
  7. js深拷贝,浅拷贝的解析以及解决方案
  8. linux创建用户,并修改分组,改变权限
  9. Kinect安装与配置(openNI2)
  10. ZHS16GBK的数据库导入到字符集为AL32UTF8的数据库