keras rl typeerror: len is not well defined for symbolic tensors. please call x.shape for shape info

摘要:
回溯(mostrecentcalllast):文件“”,第1行,在文件“/opt/python-3.7/lib/python3.7/site packages/rl/agents/dqn.py”中,第108行,在__init__ifhasattr(model.output,'__len__')andlen(model_output)中
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/python-3.7.6/lib/python3.7/site-packages/rl/agents/dqn.py", line 108, in __init__
  if hasattr(model.output, '__len__') and len(model.output) > 1:
File "/opt/python-3.7.6/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py", line 733, in __len__
  "shape information.".format(self.name))
TypeError: len is not well defined for symbolic Tensors. (activation_4/Identity:0) Please call `x.shape` rather than `len(x)` for shape information.

I have fixed the error by changing the specified line of code (i.e., 108) with:

if hasattr(model.output, '__shape__') and len(model.output.shape) > 2:

I hope this is a correct fix.

All the best,
Ciprian

P.S. I use

Keras==2.3.1

with the backend

tensorflow==2.1.0
tensorflow-estimator==2.1.0

it works for me, i using tensorflow 1.15, and keras 2.

免责声明:文章转载自《keras rl typeerror: len is not well defined for symbolic tensors. please call x.shape for shape info》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇mybatis的嵌套查询(嵌套查询nested select和嵌套结果nested results查询)区别『软件介绍』SQLServer2008 基本操作下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

StreamWriter、StreamReader 写读文件的两种方法

方法一://建立StreamWriter为写做准备   StreamWriter rw = File.CreateText(Server.MapPath(".")+"\\CreateText.txt");   //使用WriteLine写入内容   rw.WriteLine("使用File.CreateText 方法");   rw.WriteLine("...

三种Js深度学习框架介绍

谈到机器学习,我们脑海首先蹦出的编程语言是什么?一定是python。其实除了python,JavaScript也是不错的选择。都说现在是大前端时代,从移动开发、服务器端,甚至桌面软件开发(比如大名鼎鼎的VS Code),都有JavaScript的身影。   用Javascript写机器学习应用,当然不会从头开始手写机器学习算法和模型,通常会借助现有框架。我...

LSTM 详解

1、定义:什么是LSTM? 首先,我们知道最基础的神经网络是【全连接神经网络】,keras里为,dense层。Dense就是常用的全连接层,所实现的运算是output = activation(dot(input, kernel)+bias)。其中activation是逐元素计算的激活函数,kernel是本层的权值矩阵,bias为偏置向量,只有当use_b...

【STM32F429】第1章 选择RTX5的优势

论坛原始地址(持续更新):http://www.armbbs.cn/forum.php?mod=viewthread&tid=93149 第1章   选择RTX5的优势 初学ThreadX,一般都比较关心这个问题,所以把这个问题放在第一章简单的说说。这里分为七个方面跟大家进行说明。 1.1 RTX5移植难易度 1.2 RTX5上手难易度 1.3 R...

TensorFlow2.0教程-使用keras训练模型

1.一般的模型构造、训练、测试流程 1 # 模型构造 2 inputs = keras.Input(shape=(784,), name='mnist_input') 3 h1 = layers.Dense(64, activation='relu')(inputs) 4 h1 = layers.Dense(64, activation='relu...

Ubuntu18.04 + NVidia显卡 + Anaconda3 + Tensorflow-GPU 安装、配置、测试 (无需手动安装CUDA)

其中其决定作用的是这篇文章  https://www.pugetsystems.com/labs/hpc/Install-TensorFlow-with-GPU-Support-the-Easy-Way-on-Ubuntu-18-04-without-installing-CUDA-1170/ 注意兼容版本:https://devtalk.nvidia.c...