GithubHelp home page GithubHelp logo

make_vec(...) will raise error "AttributeError: can't set attribute", while vector.make(..) doesn't for customized env about gymnasium HOT 7 OPEN

BruceGeLi avatar BruceGeLi commented on July 19, 2024
make_vec(...) will raise error "AttributeError: can't set attribute", while vector.make(..) doesn't for customized env

from gymnasium.

Comments (7)

Kallinteris-Andreas avatar Kallinteris-Andreas commented on July 19, 2024

Does the issue persist with gymnasium==1.0.0a1? (note: metaworld may break though)

from gymnasium.

BruceGeLi avatar BruceGeLi commented on July 19, 2024

Hi, thanks for your reply.

Beyond this issue, I actually found some other weird bugs in v0.29, such as the asych env vector is actually not asych. The running time is propotional to the num of envs :(

I see v1.0.0a1 gets a lot of update to these vector envs. So, I will give a try, but it will take some time from us to adapt our code base to v1.0.0a1.

from gymnasium.

pseudo-rnd-thoughts avatar pseudo-rnd-thoughts commented on July 19, 2024

My guess is that the environment used has a wrapper applied to it, and you can't set the spec for a wrapper (property reasons).
Therefore, I would guess this is a bug but I don't think we will be releasing anymore v0.29 versions to fix this sadly.
I would use gym.vector.make in the meantime. Hopefully gymnasium.make_vec will be fix this in the next release.

from gymnasium.

pseudo-rnd-thoughts avatar pseudo-rnd-thoughts commented on July 19, 2024

My guess is that the environment used has a wrapper applied to it, and you can't set the spec for a wrapper (property reasons). Therefore, I would guess this is a bug but I don't think we will be releasing anymore v0.29 versions to fix this sadly. I would use gym.vector.make in the meantime. Hopefully gymnasium.make_vec will be fix this in the next release.

I'm wrong, this isn't the problem

class CustomWrapper(gym.Wrapper):
    def __init__(self, **kwargs):
        super().__init__(gym.make("CartPole-v1", disable_env_checker=True, **kwargs))

# the entry_point is directly the wrapper class which poses an issue as the Wrapper has `metadata` using a property
gym.register("TestEnv-v0", CustomWrapper)
gym.make_vec("TestEnv-v0", num_envs=1)
del gym.registry["TestEnv-v0"]

So I don't know what the issue is.
@BruceGeLi When you updated to v1.0.0, let us know if you still have an issue

from gymnasium.

Zhaohhya avatar Zhaohhya commented on July 19, 2024

I've found similar problems. I'm following the warning
WARN: gymnasium.vector.make(...) is deprecated and will be replaced by gymnasium.make_vec(...) in v1.0
Using the following code
envs = gym.make_vec("InvertedPendulum-v4", num_envs = 3, max_episode_steps=600)
it will raise an error, as

  File "C:\Users\87182\anaconda3\envs\gymnasium\lib\site-packages\gymnasium\wrappers\record_episode_statistics.py", line 98, in step
    self.episode_returns += rewards
ValueError: non-broadcastable output operand with shape (1,) doesn't match the broadcast shape (3,)

Change back to the original function
envs = gym.vector.make("InvertedPendulum-v4", num_envs = 3, max_episode_steps=600)
and it worked

from gymnasium.

BruceGeLi avatar BruceGeLi commented on July 19, 2024

My guess is that the environment used has a wrapper applied to it, and you can't set the spec for a wrapper (property reasons). Therefore, I would guess this is a bug but I don't think we will be releasing anymore v0.29 versions to fix this sadly. I would use gym.vector.make in the meantime. Hopefully gymnasium.make_vec will be fix this in the next release.

I'm wrong, this isn't the problem

class CustomWrapper(gym.Wrapper):
    def __init__(self, **kwargs):
        super().__init__(gym.make("CartPole-v1", disable_env_checker=True, **kwargs))

# the entry_point is directly the wrapper class which poses an issue as the Wrapper has `metadata` using a property
gym.register("TestEnv-v0", CustomWrapper)
gym.make_vec("TestEnv-v0", num_envs=1)
del gym.registry["TestEnv-v0"]

So I don't know what the issue is. @BruceGeLi When you updated to v1.0.0, let us know if you still have an issue

Thanks, we will have a try later and will report the result, but will take some time I think.

from gymnasium.

pseudo-rnd-thoughts avatar pseudo-rnd-thoughts commented on July 19, 2024

envs = gym.make_vec("InvertedPendulum-v4", num_envs = 3, max_episode_steps=600)

@Zhaohhya Your example doesn't produce an error, could you provide a large example that raises an error

from gymnasium.

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.