google-research / batch_rl

Offline Reinforcement Learning (aka Batch Reinforcement Learning) on Atari 2600 games
https://offline-rl.github.io/
Apache License 2.0
528 stars 74 forks source link

Ambiguous selector #18

Closed icomeaman closed 3 years ago

icomeaman commented 3 years ago

hello Rishabh Agarwal: when I try to run this step [Test for training an agent with fixed replay buffer] it always have this problem:

(python27) ➜ batch_rl git:(master) ✗ python -um batch_rl.tests.fixed_replay_runner_test \ --replay_dir=$DATA_DIR/Pong/1
Running tests under Python 3.7.3: /Users/xiayong/anaconda3/envs/python27/bin/python [ RUN ] FixedReplayRunnerIntegrationTest.testIntegrationFixedReplayREM INFO:tensorflow:####### Training the REM agent ##### I0329 15:56:52.711899 4739141120 fixed_replay_runner_test.py:81] ####### Training the REM agent ##### INFO:tensorflow:####### REM base_dir: /tmp/batch_rltests/run_2021_03_29_13_56_52 I0329 15:56:52.712044 4739141120 fixed_replay_runner_test.py:82] ####### REM base_dir: /tmp/batch_rltests/run_2021_03_29_13_56_52 INFO:tensorflow:####### replay_dir: /Users/xiayong/Pong/1 I0329 15:56:52.712151 4739141120 fixed_replay_runner_test.py:83] ####### replay_dir: /Users/xiayong/Pong/1 INFO:tensorflow:time(main.FixedReplayRunnerIntegrationTest.testIntegrationFixedReplayREM): 0.01s I0329 15:56:52.725455 4739141120 test_util.py:2076] time(main.FixedReplayRunnerIntegrationTest.testIntegrationFixedReplayREM): 0.01s [ FAILED ] FixedReplayRunnerIntegrationTest.testIntegrationFixedReplayREM [ RUN ] FixedReplayRunnerIntegrationTest.test_session [ SKIPPED ] FixedReplayRunnerIntegrationTest.test_session

ERROR: testIntegrationFixedReplayREM (main.FixedReplayRunnerIntegrationTest) FixedReplayRunnerIntegrationTest.testIntegrationFixedReplayREM Test the FixedReplayMultiHeadDQN agent.

Traceback (most recent call last): File "/Users/xiayong/batch_rl/batch_rl/tests/fixed_replay_runner_test.py", line 85, in testIntegrationFixedReplayREM train.main([]) File "/Users/xiayong/batch_rl/batch_rl/fixed_replay/train.py", line 95, in main base_run_experiment.load_gin_configs(FLAGS.gin_files, FLAGS.gin_bindings) File "/Users/xiayong/anaconda3/envs/python27/lib/python3.7/site-packages/dopamine/discrete_domains/run_experiment.py", line 56, in load_gin_configs skip_unknown=False) File "/Users/xiayong/anaconda3/envs/python27/lib/python3.7/site-packages/gin/config.py", line 1810, in parse_config_files_and_bindings includes_and_imports = parse_config_file(config_file, skip_unknown) File "/Users/xiayong/anaconda3/envs/python27/lib/python3.7/site-packages/gin/config.py", line 1764, in parse_config_file includes, imports = parse_config(f, skip_unknown=skip_unknown) File "/Users/xiayong/anaconda3/envs/python27/lib/python3.7/site-packages/gin/config.py", line 1657, in parse_config bind_parameter((scope, selector, arg_name), value) File "/Users/xiayong/anaconda3/envs/python27/lib/python3.7/contextlib.py", line 130, in exit self.gen.throw(type, value, traceback) File "/Users/xiayong/anaconda3/envs/python27/lib/python3.7/site-packages/gin/utils.py", line 58, in try_with_location augment_exception_message_and_reraise(exception, _format_location(location)) File "/Users/xiayong/anaconda3/envs/python27/lib/python3.7/site-packages/gin/utils.py", line 41, in augment_exception_message_and_reraise raise proxy.with_traceback(exception.traceback) from None File "/Users/xiayong/anaconda3/envs/python27/lib/python3.7/site-packages/gin/utils.py", line 56, in try_with_location yield File "/Users/xiayong/anaconda3/envs/python27/lib/python3.7/site-packages/gin/config.py", line 1657, in parse_config bind_parameter((scope, selector, arg_name), value) File "/Users/xiayong/anaconda3/envs/python27/lib/python3.7/site-packages/gin/config.py", line 645, in bind_parameter pbk = ParsedBindingKey(bindingkey) File "/Users/xiayong/anaconda3/envs/python27/lib/python3.7/site-packages/gin/config.py", line 508, in new configurable = _REGISTRY.get_match(selector) File "/Users/xiayong/anaconda3/envs/python27/lib/python3.7/site-packages/gin/selector_map.py", line 169, in get_match raise KeyError(err_str.format(partial_selector, matching_selectors)) KeyError: "Ambiguous selector 'FixedReplayMultiHeadDQNAgent', matches ['fixed_replay.agents.multi_head_dqn_agent.FixedReplayMultiHeadDQNAgent', 'batch_rl.fixed_replay.agents.multi_head_dqn_agent.FixedReplayMultiHeadDQNAgent']." In file "batch_rl/fixed_replay/configs/rem.gin", line 10 FixedReplayMultiHeadDQNAgent.gamma = 0.99


Ran 2 tests in 0.021s

FAILED (errors=1, skipped=1)

agarwl commented 3 years ago

This error is strange as both the ['fixed_replay.agents.multi_head_dqn_agent.FixedReplayMultiHeadDQNAgent', 'batch_rl.fixed_replay.agents.multi_head_dqn_agent.FixedReplayMultiHeadDQNAgent'] correspond to the same agent. For now, to fix this issue, you can simply replace all occurences of FixedReplayMultiHeadDQNAgent in the rem.gin file with batch_rl.fixed_replay.agents.multi_head_dqn_agent.FixedReplayMultiHeadDQNAgent so that the gin file selection is not ambiguous.