Open bionicles opened 4 years ago
function show_box_space(s)
shape = s.shape
dtype = pystr(s.dtype)
target_type = occursin("int", dtype) ? Int : Float
high = map(target_type, Array(s.high))
low = map(target_type, Array(s.low))
println("Box$shape")
@show dtype
@show high[1]
@show low[1]
return Dict("kind"=>"Box", "shape"=>shape, "dtype"=>dtype, "high"=>high, "low"=>low)
end
function show_discrete_space(s)
n = s.n
println("Discrete($n)")
return Dict("kind"=>"Discrete", "n"=>n)
end
function show_space(s)
space_repr = pystr(s)
if occursin("Discrete", space_repr)
return show_discrete_space(s)
elseif occursin("Box", space_repr)
return show_box_space(s)
else
print("WARNING: $space_repr unsupported!!!!1")
end
end
function show_spaces(env_name)
env = GymEnv(env_name)
@show env_name
println()
println("Observation Space:")
observation_space_dict = show_space(env.pyenv.observation_space)
println()
println("Action Space:")
action_space_dict = show_space(env.pyenv.action_space)
println()
close(env)
env_dict = Dict("name"=>env_name, "observation_space"=>observation_space_dict, "action_space"=>action_space_dict)
return env_dict
end
env_names = ["procgen:procgen-$stub-v0" for stub in ["bigfish","bossfight","caveflyer","chaser","climber","coinrun","dodgeball","fruitbot",
"heist","jumper","leaper","maze","miner","ninja","plunder","starpilot"]]
[show_spaces(env_name) for env_name in env_names]
^^^ I just wrote this. MIT License
Here is the result for all of the ProcGen envs:
Observation Space: Box(64, 64, 3) dtype = "uint8" high[1] = 255 low[1] = 0
Action Space: Discrete(15)
Hi @bionicles,
Thanks for your suggestions.
Could you open a PR and put this code into a examples
dir in this repo?
sorry, i'm not working in julia right now, but you're welcome to reuse the code
For architecture search across a variety of environments, it's crucial to access the parameters of the observation and action spaces.
How do you do that with this library?