One-Hot Encoding
It's common to encode categorical variables (like true
, false
or cat
, dog
) in "one-of-k" or "one-hot" form. Flux provides the onehot
function to make this easy.
julia> using Flux: onehot
+
One-Hot Encoding
It's common to encode categorical variables (like true
, false
or cat
, dog
) in "one-of-k" or "one-hot" form. Flux provides the onehot
function to make this easy.
julia> using Flux: onehot, onecold
julia> onehot(:b, [:a, :b, :c])
3-element Flux.OneHotVector:
@@ -18,14 +18,14 @@ julia> onehot(:c, [:a, :b, :c])
3-element Flux.OneHotVector:
false
false
- true
The inverse is argmax
(which can take a general probability distribution, as well as just booleans).
julia> argmax(ans, [:a, :b, :c])
+ true
The inverse is onecold
(which can take a general probability distribution, as well as just booleans).
julia> onecold(ans, [:a, :b, :c])
:c
-julia> argmax([true, false, false], [:a, :b, :c])
+julia> onecold([true, false, false], [:a, :b, :c])
:a
-julia> argmax([0.3, 0.2, 0.5], [:a, :b, :c])
-:c
Batches
onehotbatch
creates a batch (matrix) of one-hot vectors, and argmax
treats matrices as batches.
julia> using Flux: onehotbatch
+julia> onecold([0.3, 0.2, 0.5], [:a, :b, :c])
+:c
Batches
onehotbatch
creates a batch (matrix) of one-hot vectors, and onecold
treats matrices as batches.
julia> using Flux: onehotbatch
julia> onehotbatch([:b, :a, :b], [:a, :b, :c])
3×3 Flux.OneHotMatrix:
diff --git a/latest/index.html b/latest/index.html
index 51ceb6d6..7d5bbfa5 100644
--- a/latest/index.html
+++ b/latest/index.html
@@ -6,7 +6,4 @@ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
ga('create', 'UA-36890222-9', 'auto');
ga('send', 'pageview');
-
Flux: The Julia Machine Learning Library
Flux is a library for machine learning. It comes "batteries-included" with many useful tools built in, but also lets you use the full power of the Julia language where you need it. The whole stack is implemented in clean Julia code (right down to the GPU kernels) and any part can be tweaked to your liking.
Installation
Install Julia 0.6.0 or later, if you haven't already.
Pkg.add("Flux")
-# Optional but recommended
-Pkg.update() # Keep your packages up to date
-Pkg.test("Flux") # Check things installed correctly
Start with the basics. The model zoo is also a good starting point for many common kinds of models.
See GPU support for more details on installing and using Flux with GPUs.