0

VScodeでDQNを行うために、前段階としてQiitaの記事に掲載されているものを実行してみたところ、エラーが出てしまいます。
エラーが出るのは以下コードの"dqn = DQNAgent(model=model,..."の箇所です。

model = tf.keras.Sequential()
model.add(tf.keras.layers.Flatten(input_shape=(1,) + env.observation_space.shape))
model.add(tf.keras.layers.Dense(16, kernel_initializer='he_normal', activation='relu',kernel_regularizer=tf.keras.regularizers.l2(0.01)))
model.add(tf.keras.layers.Dense(16, kernel_initializer='he_normal', activation='relu',kernel_regularizer=tf.keras.regularizers.l2(0.01)))
model.add(tf.keras.layers.Dense(16, kernel_initializer='he_normal', activation='relu',kernel_regularizer=tf.keras.regularizers.l2(0.01)))
model.add(tf.keras.layers.Dense(nb_actions, activation='linear'))
print(model.summary())
memory = SequentialMemory(limit=50000, window_length=1)
policy = EpsGreedyQPolicy(eps = 0.1)
dqn = DQNAgent(model=model, nb_actions=nb_actions, memory=memory, nb_steps_warmup=10,
               target_model_update=1e-2, policy=policy)
dqn.compile(tf.keras.optimizers.Adam(learning_rate=1e-3), metrics=['mae'])

この記事この記事この記事を参考に手直ししてみたのですが、どうにも以下に示すようなエラーが出続けます。

TypeError: Keras symbolic inputs/outputs do not implement `__len__`. 
You may be trying to pass Keras symbolic inputs/outputs to a TF API that does not register dispatching,
 preventing Keras from automatically converting the API call to a lambda layer in the Functional Model. 
This error will also get raised if you try asserting a symbolic input/output directly.

関係のありそうなライブラリのバージョンは、
tensorflow→2.10.0
keras→2.10.0
keras-rl2→1.0.5
gym→0.26.1

となっております。
どなたかご助力いただけると幸いです。

1

0

この質問に回答するには、ログインする必要があります。

のタグが付いた他の質問を参照する。