Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List index out of range #7

Open
jaejaywoo opened this issue Jun 14, 2018 · 1 comment
Open

List index out of range #7

jaejaywoo opened this issue Jun 14, 2018 · 1 comment

Comments

@jaejaywoo
Copy link

Hello, I was running the agent on CollectMineralShards, and I often encountered following index error.

Traceback (most recent call last):
  File "/home/hyunjaewoo/.virtualenvs/pysc2/lib/python3.5/site-packages/pudb/__init__.py", line 119, in runscript
    dbg._runscript(mainpyfile)
  File "/home/hyunjaewoo/.virtualenvs/pysc2/lib/python3.5/site-packages/pudb/debugger.py", line 457, in _runscript
    self.run(statement, globals=globals_, locals=locals_)
  File "/usr/lib/python3.5/bdb.py", line 431, in run
    exec(cmd, globals, locals)
  File "<string>", line 1, in <module>
  File "run.py", line 189, in <module>
    main()
  File "run.py", line 164, in main
    result = runner.run_batch(train_summary=write_summary)
  File "/home/hyunjaewoo/research/pysc2-rl-agents/rl/agents/a2c/runner.py", line 77, in run_batch
    actions = mask_unused_argument_samples(actions)
  File "/home/hyunjaewoo/research/pysc2-rl-agents/rl/agents/a2c/runner.py", line 171, in mask_unused_argument_samples
    unused_types = set(ACTION_TYPES) - set(FUNCTIONS._func_list[a_0].args)
IndexError: list index out of range

After I looked up what was going on, I figured out that often times, variable a_0 was assigned to a value 524, which is the actual size of the action.FUNCTIONS and which causes the index error in the code.

This actually happens in both of the functions mask_unused_argument_samples() and actions_to_pysc2(), so I am thinking that the problem is somewhere in the process of sampling the actions from the policy, but I couldn't find the cause. Have you ever encountered similar error message?

@iamduyun
Copy link

def mask_unused_argument_samples(actions):
"""Replace sampled argument id by -1 for all arguments not used
in a steps action (in-place).
"""
fn_id, arg_ids = actions
for n in range(fn_id.shape[0]):
a_0 = fn_id[n]
if a_0 == G_FUNCTION_NUMBER: #modified by roger
fn_id[n], a_0 = 0, 0
unused_types = set(TYPES) - set(FUNCTIONS._func_list[a_0].args)
for arg_type in unused_types:
arg_ids[arg_type][n] = -1
return (fn_id, arg_ids)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants