GithubHelp home page GithubHelp logo

Comments (10)

SweetPin avatar SweetPin commented on July 24, 2024 9

This may be a problem with the gym version.You try to change the gym version to 0.10.5 and see if it works.

from multiagent-particle-envs.

indhra avatar indhra commented on July 24, 2024 1

remove
from gym.spaces import prng
and replace
random_array = prng.np_random.rand(self.num_discrete_space)
with

random_array = np.random.RandomState().rand(self.num_discrete_space)

@christopherhesse
please close

from multiagent-particle-envs.

christopherhesse avatar christopherhesse commented on July 24, 2024 1

This repo should probably have the correct gym version required in https://github.com/openai/multiagent-particle-envs/blob/master/setup.py#L12 instead of just choosing the latest.

from multiagent-particle-envs.

AmulyaReddy99 avatar AmulyaReddy99 commented on July 24, 2024 1

@christopherhesse
thanks for quick reply
can u help me out with the following code

OBSERVATION SPACE IS GIVING ERROR

import numpy as np
import gym

from keras.models import Sequential
from keras.layers import Dense, Activation, Flatten
from keras.optimizers import Adam

from rl.agents.dqn import DQNAgent
from rl.policy import EpsGreedyQPolicy
from rl.memory import SequentialMemory

Building the environment

env = make_env('simple_adversary')

np.random.seed(0)
env.seed(0)

Extracting the number of possible actions

num_actions = env.action_space[0].n # first agent actions changing this vaue will be another agent
print(num_actions)

Layers

agent = Sequential()

print(env.observation_space[0].shape,type(env.observation_space[0]))

agent.add(Flatten(input_shape =(1, ) + (env.observation_space[0]).shape))

agent.add(Dense(16))
agent.add(Activation('relu'))
agent.add(Dense(num_actions))
agent.add(Activation('linear'))
agent.summary()

Building model

strategy = EpsGreedyQPolicy()
memory = SequentialMemory(limit = 10000, window_length = 1)
dqn = DQNAgent(model = agent, nb_actions = num_actions,
memory = memory, nb_steps_warmup = 10, target_model_update = 1e-2, policy = strategy)
dqn.compile(Adam(lr = 1e-3), metrics =['mae'])

Visualizing the training

dqn.fit(env, nb_steps = 5000, visualize = False, verbose = 2)

testing

dqn.test(env, nb_episodes = 5, visualize = False)

Please use the below for loading env

import multiagent.scenarios as scenarios
scenario = scenarios.load('simple_adversary.py').Scenario()
world = scenario.make_world()
env = MultiAgentEnv(world, scenario.reset_world, scenario.reward, scenario.observation, info_callback=None, shared_viewer = False)

Now, you can proceed with the code for adding neural networks.

Hope this helps

from multiagent-particle-envs.

Privilger avatar Privilger commented on July 24, 2024

From README of gym:

2019-02-06 (v0.11.0)
remove gym.spaces.np_random common PRNG; use per-instance PRNG instead.

from multiagent-particle-envs.

ZechenLiu avatar ZechenLiu commented on July 24, 2024

Have you solved it yet?
I'm also working on the same problem. My gym version is v0.14.0 , my python version is 3.6.x. Are those versions over high that will forbid running it ?

from multiagent-particle-envs.

canyon avatar canyon commented on July 24, 2024

Have you solved it yet?
I'm also working on the same problem. My gym version is v0.14.0 , my python version is 3.6.x. Are those versions over high that will forbid running it ?

i can run it with the gym version at 0.10.5.

from multiagent-particle-envs.

zhaolongkzz avatar zhaolongkzz commented on July 24, 2024

change to an old version (0.10.5) is ok, you'd better change like this #53

from multiagent-particle-envs.

indhra avatar indhra commented on July 24, 2024

@christopherhesse
thanks for quick reply
can u help me out with the following code

OBSERVATION SPACE IS GIVING ERROR

import numpy as np
import gym

from keras.models import Sequential
from keras.layers import Dense, Activation, Flatten
from keras.optimizers import Adam

from rl.agents.dqn import DQNAgent
from rl.policy import EpsGreedyQPolicy
from rl.memory import SequentialMemory

Building the environment

env = make_env('simple_adversary')

np.random.seed(0)
env.seed(0)

Extracting the number of possible actions

num_actions = env.action_space[0].n # first agent actions changing this vaue will be another agent
print(num_actions)

Layers

agent = Sequential()

print(env.observation_space[0].shape,type(env.observation_space[0]))

agent.add(Flatten(input_shape =(1, ) + (env.observation_space[0]).shape))

agent.add(Dense(16))
agent.add(Activation('relu'))
agent.add(Dense(num_actions))
agent.add(Activation('linear'))
agent.summary()

Building model

strategy = EpsGreedyQPolicy()
memory = SequentialMemory(limit = 10000, window_length = 1)
dqn = DQNAgent(model = agent, nb_actions = num_actions,
memory = memory, nb_steps_warmup = 10, target_model_update = 1e-2, policy = strategy)
dqn.compile(Adam(lr = 1e-3), metrics =['mae'])

Visualizing the training

dqn.fit(env, nb_steps = 5000, visualize = False, verbose = 2)

testing

dqn.test(env, nb_episodes = 5, visualize = False)

from multiagent-particle-envs.

AmulyaReddy99 avatar AmulyaReddy99 commented on July 24, 2024

Have you solved it yet?
I'm also working on the same problem. My gym version is v0.14.0 , my python version is 3.6.x. Are those versions over high that will forbid running it ?

I am using same versions gym==0.14.0 and python3.6. It is working fine for me.

from multiagent-particle-envs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.