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

TypeError: tuple indices must be integers or slices, not tuple #3

Open
oatuy opened this issue Apr 4, 2018 · 3 comments
Open

TypeError: tuple indices must be integers or slices, not tuple #3

oatuy opened this issue Apr 4, 2018 · 3 comments

Comments

@oatuy
Copy link

oatuy commented Apr 4, 2018

Hello.

Thanks for your codes, but I got some errors.

I’m using your env.py, so I renamed the env folder and changed from env import envs to import env as envs.
Is it correct?

Since I only have CPU, I change self.sess = tf.Session(config=tf.ConfigProto(log_device_placement=True)) to
self.sess = tf.Session()
But maybe this is not related to the errors.

When I ran the codes, I get such errors:

Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydev_run_in_console.py", line 53, in run_file
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File “xx/scalable_maddpg/main.py", line 44, in <module>
    action = maddpg.noise_action(current_state)
  File “xx/scalable_maddpg/maddpg.py", line 158, in noise_action
    action = self.action(state)
  File “xx/scalable_maddpg/maddpg.py", line 138, in action
    action[ii,:] = self.agents[ii].action(state[ii,:])
TypeError: tuple indices must be integers or slices, not tuple

I tried to solve it by changing action[ii,:] = self.agents[ii].action(state[ii,:]) to action[ii,:] = self.agents[ii].action(state[ii]), but it lead to other errors.

Do you have some idea of the errors?
Thank you.

@livey
Copy link
Owner

livey commented Apr 5, 2018

Since you are using the env.py as the environment, the prey policy should be implemented outside the environment by yourself. This is a little different from the modified gym environment which we implement the prey policy inside the environment. You can refer this repository to see how to use env.py correctly.

I am not sure whether this is caused by the environment.

@dcy0324
Copy link

dcy0324 commented Dec 17, 2019

Hello! I got the same error when running the main.py main_add_agents.py, slow_replay.py files, as shown below:
Traceback (most recent call last):
   File "main.py", line 16, in
     Env = envs.Environ (num_agents, max_edge)
   File "/home/dcy/MADDPG/scalable_maddpg-master/env/envs.py", line 23, in init
     = self.create_env (num_agents,)
   File "/home/dcy/MADDPG/scalable_maddpg-master/env/envs.py", line 37, in create_env
     shared_viewer = False)
   File "env / multiagent / environment.py", line 71, in init
     self.observation_space.append (spaces.Box (low = -np.inf, high = + np.inf, shape = (obs_dim),))
   File "/home/dcy/anaconda3/lib/python3.6/site-packages/gym/spaces/box.py", line 34, in init
     gym.Space .__ init __ (self, shape, dtype)
   File "/home/dcy/anaconda3/lib/python3.6/site-packages/gym/core.py", line 202, in init
     self.shape = None if shape is None else tuple (shape)
TypeError: 'int' object is not iterable
Excuse me, what is the reason for this?

@livey
Copy link
Owner

livey commented Dec 17, 2019

Would you please delete the env folder and try our env.py implementation. You can refer this repository .

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

3 participants