-
-
Notifications
You must be signed in to change notification settings - Fork 606
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
Configurable dtypes for all layers and initializers #513
Conversation
Changes: * All layers and initializers now optionally take a dtype argument. * There is a new variable Flux.FloatX that defines the default floating point type (currently Float32). * defined eltype(TrackedReal{T}) = T
I realized that I forgot to modify the optimizers to take an optional dtype argument that is defaulted to |
I personally prefer just use a type parameter. It might not be type stable with dtype. And this is consistent with most other Julia objects, e.g Array |
The function |
@Roger-luo Would adding a type parameter still still support a user directly passing in their own weight matrices? For instance, if a user tries to create a Dense layer with @mcabbott I like this syntax. It would be nice to avoid the initial allocation in float64 (or any non-desired precision). This could be particularly painful with large embedding layers and/or running in a memory-limited environment. |
Yes, it will prevent user from using different precision within a single layer, .e.g
Apparently, when you pass an instance of If someone want to use And I'll vote for @mcabbott 's syntax as well. |
One more thought is that, if I understand right, |
Thanks for this patch, and apologies for not getting back on it sooner. I think this is generally the right idea and very useful functionality but I decided to do it a little differently; in particular, rather than adding options to layers we can make this more similar to Thanks for pushing this along anyhow! Let me know if I can help out with any other contributions. |
Hi
I thought Flux could benefit from easier configuration of dtypes, so I tried implementing something myself.
I based the
FloatX
default dtype variable off of Theano: http://deeplearning.net/software/theano/library/config.html .Things I'm looking for feedback on:
FloatX
. Should we makeFloatX
configurable by environment variable or from a config variable? Is there a good way the user could setFloatX
before all of the functions with optional argumentdtype=FloatX
get interpreted?(::Type, size...)
method. Is that OK at this point?Changes:
floating point type (currently Float32).