前提・実現したいこと
ここに質問の内容を詳しく書いてください。
https://qiita.com/tanuk1647/items/7b8c2f0d09330cbfacd2
上記のサイトを参考に、強化学習を学習しようとしていたのですが、最初から躓いてしまい、困っております。エラーの意味と対処法について伺いたいです。
発生している問題・エラーメッセージ
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-11-c7ea9d334d3c> in <module> ----> 1 d = DQNJankenGlico(strategy=Strategy.RANDOM, recycle=True) 2 h = d.test(nb_episodes=1, verbose=1, visualize=True) 3 visualize_positions(d.env) 4 visualize_hands(d.env) <ipython-input-7-5f2addb0abfc> in __init__(self, strategy, recycle) 399 memory = SequentialMemory(limit=50000, window_length=1) 400 policy = BoltzmannQPolicy(tau=1.) --> 401 self.dqn = DQNAgent(model=self.model,nb_actions=self.nb_actions,memory=memory,nb_steps_warmup=1000,target_model_update=1e-2,policy=policy) 402 self.dqn.compile(Adam(lr=1e-3), metrics=[]) 403 ~/opt/anaconda3/lib/python3.8/site-packages/rl/agents/dqn.py in __init__(self, model, policy, test_policy, enable_double_dqn, enable_dueling_network, dueling_type, *args, **kwargs) 106 107 # Validate (important) input. --> 108 if hasattr(model.output, '__len__') and len(model.output) > 1: 109 raise ValueError('Model "{}" has more than one output. DQN expects a model that has a single output.'.format(model)) 110 if model.output._keras_shape != (None, self.nb_actions): ~/opt/anaconda3/lib/python3.8/site-packages/keras/engine/keras_tensor.py in __len__(self) 209 210 def __len__(self): --> 211 raise TypeError('Keras symbolic inputs/outputs do not ' 212 'implement `__len__`. You may be ' 213 'trying to pass Keras symbolic inputs/outputs ' 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. ### 該当コード 上記サイトのモジュールのインポートが記載されているコードについてはエラーなし。 その直後の、一回戦についての下記のコードでエラーが発生。
d = DQNJankenGlico(strategy=Strategy.RANDOM, recycle=True)
h = d.test(nb_episodes=1, verbose=1, visualize=True)
visualize_positions(d.env)
visualize_hands(d.env)
### 試したこと 他のサイトも参考にしつつ、モジュールについてはインストールの確認を行なった。 ### 補足情報(FW/ツールのバージョンなど) 初めての質問ですので、説明がわかりづらい点があるかと思われますが、ご教授いただけると幸いです。
あなたの回答
tips
プレビュー