python - 使用 Keras 后端函数时出现 InvalidArgumentError

标签 python keras reinforcement-learning keras-layer keras-rl

我正在使用 Keras 后端函数来计算强化学习设置中的梯度,以下是代码片段。对于此代码,我也收到以下错误。可能是什么原因造成的?

       1  X = K.placeholder(shape=(None, 32, 32, 3)) 
       2  train_fxn = K.function([X], [], updates=updates)
       3  X = self.states[0].reshape(1, 32, 32, 3)
       4  train_fxn([X])

错误是

       InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'sequential_2_input_1' with dtype float and shape [?,32,32,3]
     [[Node: sequential_2_input_1 = Placeholder[dtype=DT_FLOAT, shape=[?,32,32,3], _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]]

最佳答案

它提示您提供的向量要么形状不正确,要么包含 float 以外的值。

您向第 1 行的向量传递了一个 None 值,这可能会导致错误。

关于python - 使用 Keras 后端函数时出现 InvalidArgumentError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50105734/

相关文章:

c++ - Epsilon Greedy 在少量武器上表现优于 UCB

python - fabric 不适用于我的 python/django 代码

Python 3 : win32com object. 大小抛出异常 (pywintypes.com_error)

tensorflow - 模块 'tensorflow' 没有属性 'get_default_graph'

machine-learning - 来自 for 循环的 Keras LSTM,使用具有自定义层数的函数式 API

python - 【强化学习】为什么我的reward变成0就结束了?我在健身房环境方面遇到了一些麻烦

python - Python 应用程序需要 init.d 脚本

python - 如何使用 Python 创建 WIFI 启动页面

python - 如何将多个 NumPy 数组输入 Keras 中的深度学习网络?

reinforcement-learning - batch q learning和growing batch q learning的区别