【发布时间】:2020-01-22 14:22:21
【问题描述】:
我正在尝试使用 Keras-rl 实现 DQN 代理。问题是当我定义我的模型时,我需要在架构中使用 LSTM 层:
model = Sequential()
model.add(Flatten(input_shape=(1, 8000)))
model.add(Reshape(target_shape=(200, 40)))
model.add(LSTM(20))
model.add(Dense(3, activation='softmax'))
return model
执行 rl-agent 我得到以下错误:
RuntimeError: Attempting to capture an EagerTensor without building a function.
这与LSTM的使用和以下代码行有关:
tf.compat.v1.disable_eager_execution()
使用 Dense 层而不是 LSTM:
model = Sequential()
model.add(Flatten(input_shape=(1, 8000)))
model.add(Dense(20))
model.add(Dense(3, activation='softmax'))
return model
并保持禁用急切执行我没有以前报告的错误。如果我删除禁用 LSTM 层的急切执行,我会遇到其他错误。
谁能帮我理解错误的原因?
【问题讨论】:
标签: keras tensorflow2.0 reinforcement-learning keras-rl