Git Product home page Git Product logo

Comments (2)

Kautenja avatar Kautenja commented on June 12, 2024

for the observation space, environments define an observation_space property (a proprietary gym object for spaces). To get the raw shape of the numpy array state use observation_space.shape. You can also sample from the space using observation_space.sample(). Heres a quick test script

from gym_super_mario_bros import make


env = make('SuperMarioBros-v0')
print(env.observation_space)
print(env.observation_space.shape)
print(env.observation_space.sample())

By state size, I'm assuming you mean the number of bytes required for a given state? There is no direct command but the calculation is as follows:

f = 256 * 240 * 3 = 184,320 # the number of bytes per frame (tensor)
r = 4  # the number of bytes for a reward (float)
d = 1 # the number of bytes for a done flag (boolean)
s = f + r + d = 184,325 bytes

I made a script to get the empirical state size from the

import sys
import numpy as np
from gym_super_mario_bros import make


env = make('SuperMarioBros-v0')
env.reset()
state, reward, done, info = env.step(0)


size = (
    np.prod(state.shape) * state.itemsize +
    sys.getsizeof(reward) +
    sys.getsizeof(done)
)


print('{}B per state'.format(size))

I get 184368B per state when I run the above snippet. It appears that both booleans and floats are actually allocated 24 bytes.

from gym-super-mario-bros.

rtang23 avatar rtang23 commented on June 12, 2024

You're a goddam hero!

from gym-super-mario-bros.

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.