当前位置: 首页 > news >正文

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

 NotImplementedError: Cannot convert a symbolic Tensor (lstm/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
numpy                   1.21.6

 

 

https://blog.csdn.net/FL1768317420/article/details/136431685

有几个方法:
1.降低numpy的版本到1.19.5

pip install numpy==1.19.2  【可行


2.降低Python的版本到3.6


3.修改array_ops.py

 

找到array_ops.py,我的在
E:\Anaconda3\envs\tensorflow\Lib\site-packages\tensorflow\python\ops\array_ops.py
根据错误提示,可以找到这个文件位置。
在文件中,增加

from tensorflow.python.ops.math_ops import reduce_prod 

 然后找到

def _constant_if_small(value, shape, dtype, name) 

定义,
原代码是这样的: 

图片

 

 把它修改为: 

图片

 

 

 

 

def creatModel():
model.add(LSTM(train_features.shape, input_shape=(train_features.shape, n_features)))

 

NotImplementedError: Cannot convert a symbolic Tensor (lstm/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


 

http://www.zskr.cn/news/16305.html

相关文章:

  • HTML基础学习 - 教程
  • 7_如何构建知识图谱
  • WPF ContentControl Content Binding
  • 盛世华诞 举国同庆|热烈庆祝 LEWISAK 英勇重创消火栓 1 周年!
  • 完整教程:<el-table>构建树形结构
  • CF2115 VP 记录
  • 深入解析:低秩矩阵、奇异值矩阵和正交矩阵
  • POLIR-Society-Philosophy- Hegels 形而上学System Philosophy Dialectics 系统化哲学辩证法: 自由意志+封闭的绝对精神
  • luogu P8816 [CSP-J 2022] 上升点列 题解
  • 集成测试 maestro-我的第一个flow以及第一次云端测试 - 详解
  • 2025 年生物除臭设备厂家最新推荐排行榜:覆盖污水处理厂 / 垃圾中转站等多场景,助力企业精准挑选优质设备
  • 从理念到沙盘:用悟空博弈模拟器点亮人机共治的曙光
  • Perplexity发布搜索API,驱动下一代AI应用开发
  • 20251005 总结
  • OKR1
  • 钉钉红包性能优化之路 - 实践
  • 2025 --【J+S 二十连测】-- 第二套 总结
  • 如何将 WSL 的 Ubuntu-24.04 迁移到其他电脑 - 详解
  • 题解:Luogu P11976 [KTSC 2021] 通信网络 / communication
  • 弦振动方程
  • 理论构建尝试整理
  • 基于springboot的家政服务预约系统 - 指南
  • 05-springAOP的实现
  • 2048小游戏C++板来啦! - 指南
  • 详细介绍:vue+cesium示例:3Dtiles三维模型高度调整(附源码下载)
  • st表 + 变形的djs (好题
  • 李臻20242817_安全文件传输系统项目报告_第14周 - 指南
  • 33 ACwing 294 Count The Repetitions 题解
  • 11 ACwing 281 Coins 题解
  • 4 ACwing 274 Mobile Service 题解