Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the fundamental spaces #7

Merged
merged 14 commits into from
Apr 7, 2019

Conversation

kraftpunk97-zz
Copy link
Contributor

@kraftpunk97-zz kraftpunk97-zz commented Mar 29, 2019

PR with reference to this issue #5
seed and copy functions still need to be implemented. Modified CartPole.jl (CartPole-v1.1.jl) to run on these spaces.

@tejank10 tejank10 self-requested a review March 29, 2019 15:12
Copy link
Contributor

@tejank10 tejank10 left a comment

Choose a reason for hiding this comment

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

Thanks @kraftpunk97 for great work!

Discrete(N::Int) = new(N, Int64)
end

sample(self::Discrete) = rand(1:self.n)
Copy link
Contributor

Choose a reason for hiding this comment

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

self -> d (or anything else which would imply that given object is a Discrete when read)

Copy link
Contributor Author

@kraftpunk97-zz kraftpunk97-zz Mar 31, 2019

Choose a reason for hiding this comment

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

@tejank10 A little confused here. Are you suggesting something like sample(discrete_obj::Discrete) = rand(1:discrete_obj.n)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, something like that.

as_int = Int.(x)
catch InexactError
return false
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Clever use of try catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👌👍


sample(self::MultiBinary) = (self.dtype).(rand(0:1, self.n))

contains(self::MultiBinary, x) = all(boolor.(x .== 0, x .== 1))
Copy link
Contributor

Choose a reason for hiding this comment

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

Any particular reason for introducing boolor? Can we do all(x .== 0 .| x .== 1)?

Copy link
Contributor Author

@kraftpunk97-zz kraftpunk97-zz Mar 31, 2019

Choose a reason for hiding this comment

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

Sorry about that, I was just testing something and I forgot to remove that function. Consider it fixed...


contains(self::MultiBinary, x) = all(boolor.(x .== 0, x .== 1))

Base.:(==)(self::MultiBinary, other::MultiBinary) = return self.n == other.n
Copy link
Contributor

Choose a reason for hiding this comment

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

return can be dropped here

@kraftpunk97-zz
Copy link
Contributor Author

@tejank10 Made changes as requested. Please review and verify.

@tejank10
Copy link
Contributor

tejank10 commented Apr 6, 2019

Great! I intend to replace CartPole with CartPole1.1, if the examples in model-zoo are not breaking.

@kraftpunk97-zz
Copy link
Contributor Author

Made the necessary changes. Please verify.

@tejank10 tejank10 merged commit 94dcc3d into FluxML:master Apr 7, 2019
@tejank10
Copy link
Contributor

tejank10 commented Apr 7, 2019

Great work @kraftpunk97 , Thanks!

@kraftpunk97-zz
Copy link
Contributor Author

I have never experienced joy like this before. Thanks for sticking it out with me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants