-
-
Notifications
You must be signed in to change notification settings - Fork 610
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
Don't extend base functions on base types #24
Conversation
@MikeInnes hello? |
test/recurrent.jl
Outdated
@@ -13,5 +13,5 @@ end | |||
_, ys = apply(unroll1(r).model, xs, (r.y.x,)) | |||
@test ys[1] == tanh(xs[1] * r.Wxy.x .+ r.y.x * r.Wyy.x .+ r.by.x) | |||
ru = unroll(r, 3) | |||
ru(batchone(Seq(squeeze.(xs))))[1] == squeeze.(ys) | |||
ru(batchone(Seq((x->squeeze(x,1)).(xs))))[1] == (x->squeeze(x,1)).(ys) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be squeeze.(xs, 1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
of course, not sure why I didn't use that first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
I think a nicer solution would be to add this method to Base, to be honest. |
That should be done via a PR to base (then backported via Compat once merged), not potentially concealing bugs in unrelated code by doing it in some package. And I don't think it makes much sense given the docstring is
Unless there are many of these dimension arguments that default to 1 in other functions that I'm not thinking of. |
Could give this a local |
Can we move on this? Changing the behavior of totally unrelated code depending on whether or not this package is imported is not okay. |
Bump again, this would be incompatible with the proposed meaning in JuliaLang/julia#22000, all the more reason it shouldn't be extended here. |
Perhaps it would be better for Flux to have its own, unexported |
Sure, that works too, done. |
@MikeInnes fwiw, a bunch of the discussion in the above linked issue basically boiled down to me realizing that for my use cases, what I really wanted was to just use |
In this case it comes up because the first dim is a batch – but often you just want to work with one (N-d) sample, so it's convenient to wrap and unwrap that in a batch of size 1. So Of course, it'd be much nicer to have batching be first class in the type system rather than representing it implicitly like this, but that's another project. |
Please don't monkey-patch Base, that has global side effects