I searched a bit, but it remains unclear to me what 0.01f0x
is in the Flux docs:
While one could change the activation function (e.g. to use
0.01f0x
), the idiomatic (and safe way) …
Perhaps a typo?
I searched a bit, but it remains unclear to me what 0.01f0x
is in the Flux docs:
While one could change the activation function (e.g. to use
0.01f0x
), the idiomatic (and safe way) …
Perhaps a typo?
0.01f0
is how you (can) type 0.01 as a Float32
in Julia, and that is multiplied with x
:
julia> x = 2
2
julia> 0.01f0x
0.02f0
Thanks, my bad: I read that we can omit the *
in Julia, but didn’t internalize it yet.
I’d argue that it’s bad style to omit the *
in this case, since it makes it harder to read the numeric literal. There’s also an inconsistency between float and byte literals for this behavior:
julia> x = 0
0
julia> 0f0x
0.0f0
julia> 0x0x
ERROR: syntax: invalid numeric constant "0x0x"
Stacktrace:
[1] top-level scope at REPL[14]:0
[2] eval(::Module, ::Any) at ./boot.jl:331
[3] eval_user_input(::Any, ::REPL.REPLBackend) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
[4] run_backend(::REPL.REPLBackend) at /Users/alexames/.julia/packages/Revise/MgvIv/src/Revise.jl:1023
[5] top-level scope at none:0
julia> 0x0*x
0
…which makes sense, since we need to handle e.g.
julia> a = 2
2
julia> 0x0a
0x0a
…but for the sake of clarity, I would only ever use the implicit multiplication syntax for undecorated numeric literals like 20.0x
(never 2e1x
).
Good point. And probably they should not be printed this way:
julia> :(2 * a)
:(2a)
julia> :(2f0 * a)
:(2.0f0a)
julia> :(0x0 * a)
:(0x00a)
julia> 0x00a == 10
true