1.报错 问题:(来自《Python深度学习》P164-165)

在运行以下代码的时候,报错:Cannot convert a symbolic Tensor (simple_rnn/strided_slice:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported.

# 只返回最后一个时间步的输出from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Embedding, SimpleRNNmodel = Sequential()
model.add(Embedding(10000, 32))
model.add(SimpleRNN(32))
model.summary()

2. 解决方法:

查了一下,当时用的numpy版本:

疑问:会不会是 numpy版本 太高了导致的?

于是,正好有个低版本的虚拟环境,其numpy版本为:

重新运行了上述代码,发现有Warning,但无伤大雅,可以运行: 

WARNING:tensorflow:From D:\QLDownload\AnacondaDon\envs\python37\lib\site-packages\tensorflow\python\keras\initializers.py:119: calling RandomUniform.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.
Instructions for updating:
Call initializer instance with the dtype argument instead of passing it to the constructor
WARNING:tensorflow:From D:\QLDownload\AnacondaDon\envs\python37\lib\site-packages\tensorflow\python\ops\init_ops.py:1251: calling VarianceScaling.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.
Instructions for updating:
Call initializer instance with the dtype argument instead of passing it to the constructor
Model: "sequential"
_________________________________________________________________
Layer (type)                 Output Shape              Param #
=================================================================
embedding (Embedding)        (None, None, 32)          320000
_________________________________________________________________
simple_rnn (SimpleRNN)       (None, 32)                2080
=================================================================
Total params: 322,080
Trainable params: 322,080
Non-trainable params: 0
_________________________________________________________________

BTW,虚拟环境的其他配置为:

scipy==1.3.0
Keras==2.2.4
numpy==1.16.4
networkx==2.1
tensorflow_gpu==1.14.0
scikit_learn==0.21.2
tensorflow==1.14.0

Cannot convert a symbolic Tensor (simple_rnn/strided_slice:0) to a numpy array. 报错 (解决方法)相关推荐

  1. 解决Cannot convert a symbolic Tensor (lstm/strided_slice:0) to a numpy array.

    pip install numpy==1.18.1

  2. NotImplementedError: Cannot convert a symbolic Tensor (lstm/strided_slice:0) to a numpy array.

    这是numpy版本与tensorflow版本不兼容导致的 tensorflow2.2    +  numpy1.19.2表示没问题.

  3. NotImplementedError: Cannot convert a symbolic Tensor (while/add_8:0) to a numpy array.

    代码: 报错如下: 将np.power()改成**就解决了,猜测是numpy包的原因

  4. Redis 5.0.3默认配置启动报错解决方法

    Redis 5.0.3默认配置启动报错解决方法 参考文章: (1)Redis 5.0.3默认配置启动报错解决方法 (2)https://www.cnblogs.com/miclesvic/p/1031 ...

  5. 【工具】更新arduino最新esp8266库离线安装包3.0.1、ESP32库离线安装包1.0.6,库编译报错解决方法...

    公众号关注 "DLGG创客DIY" 设为"星标",重磅干货,第一时间送达. 210806更新ESP32和ESP8266最新离线安装包下载地址.     因为各种 ...

  6. mysql8.0设置用户权限_mysql8.0建立用户授予权限报错解决方法

    我遇到错误一:Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to ...

  7. mysql8.0.11创建用户报错_mysql8.0创建用户授予权限报错解决方法

    我遇到错误一:Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to ...

  8. mysql8.0创建用户授予权限报错解决方法

    Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your My ...

  9. Android Studio support 26.0.0-alpha1 Failed to resolve: com.android.support:appcompat-v7:27.+ 报错解决方法

    Android Studio support 26.0.0-alpha1 Failed to resolve: com.android.support:appcompat-v7:27.+ 报错解决方法 ...

  10. Mysql8.0.16 连接包报错解决方法

    Mysql8.0.16 连接包报错解决方法 Mysql8.0 .16连接包报错: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized o ...

最新文章

  1. www服务器提供的第一个信息页面,第14章WWW服务
  2. javascript函数上的prototype属性的理解
  3. Go中的函数也是一种数据类型,可以赋值给一个变量
  4. 基于HTML5技术的电力3D监控应用(二)
  5. java中局部变量和成员变量
  6. Java 输出指定目录下的所有文件
  7. read 和write
  8. Java 获取昨天、当前、明天的时间
  9. python简单GUI(模拟记事本)
  10. eclipse的workspace和working set
  11. Golang 须知知识点
  12. 深度LINUX不喜欢
  13. 复变函数(第五版)课后答案 余家荣 版 课后习题答案 高等教育出版社 第一章 课后题答案与解析
  14. SQL SERVER 不允许保存更改
  15. sudo chmod 755 ....指令分析
  16. 用计算机画图教案,电脑绘画美术教案设计
  17. 扫地机器人单扫和双扫_扫地机器人初体验 懒人神器还是逗猫的塑料玩具
  18. python做测试小工具_自制快速冒烟测试小工具--基于python多线程(2)
  19. WVGA与HVGA、QVGA详细解答
  20. Java中的新生代和老生代

热门文章

  1. nginx上传文件大小报错500的解决办法
  2. tableau 日周月筛选器_自定义日期格式
  3. 高项论文(进度管理2)
  4. matlab 椭圆积分函数,第一类完全椭圆积分
  5. 宝塔面板关键目录解析
  6. JS中的this指向
  7. 比“虚幻4”还牛逼的游戏引擎 到底有多神奇?
  8. html5怎么设置字体位置,css如何设置字体位置
  9. android 内存清理命令,安卓手机内存怎么清理 安卓手机内存清理方法【图文】
  10. 网站视频倍速播放和进度自定义调整