Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Envs/classic_control/Pendulum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function step!(env::PendulumEnv, u)
g, m, l, dt = 10f0, 1f0, 1f0, env.dt

v = clamp.(u, -env.max_torque, env.max_torque)
env.last_u = Tracker.data(v)[1] # for rendering
env.last_u = v[1] # for rendering

costs = angle_normalize.(θ).^2 .+ 1f-1(θ̇ .^2) .+ 1f-3(u.^2)

Expand Down
10 changes: 2 additions & 8 deletions src/Envs/env_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,7 @@ Returns the observational state of the environment. The original state can
be accessed by `\`env._env.state\``.
"""
function state(env::EnvWrapper)
try
return _get_obs(env._env)
catch y
if isa(y, UndefVarError) || isa(y, MethodError)
return env._env.state
end
end
return _get_obs(env._env)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to get rid of the catch?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't recall exactly what the error message was that caused me to remove it. Maybe Zygote can't differentiate through it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes we don't support try blocks in zygote yet.

But this would seem to break Gym's assumptions about what to do in case of an error here. I'm happy to have a wrapper method that would dispatch accordingly to get rid of try block

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could have a _get_obs which by default returns env._env.state

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have that dispatched correctly and have this merged then?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand enough about this to implement "correct dispatch", but I think you can edit the pull request.

end


Expand All @@ -65,4 +59,4 @@ function testmode!(env::EnvWrapper, val::Bool=true)
end

trainable(env::EnvWrapper) = env.train
game_over(env::EnvWrapper) = env.done
game_over(env::EnvWrapper) = env.done
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting error

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, funny. I didn't realize I had touched that line. I had used the web editor. If this is a problem, I think you have permission to fix this inline.

1 change: 0 additions & 1 deletion src/Gym.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Gym

using Flux
using Flux.Tracker

#Spaces
include("Spaces/Space.jl")
Expand Down