Skip to content

Commit 1a57f7d

Browse files
committed
fix docs, perhaps could be shortened too
1 parent 7b851f6 commit 1a57f7d

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

docs/src/data/onehot.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ It's common to encode categorical variables (like `true`, `false` or `cat`, `dog
66
julia> using Flux: onehot, onecold
77
88
julia> onehot(:b, [:a, :b, :c])
9-
3-element Flux.OneHotVector{3,UInt32}:
10-
0
9+
3-element OneHotVector(::UInt32) with eltype Bool:
10+
1111
1
12-
0
12+
1313
1414
julia> onehot(:c, [:a, :b, :c])
15-
3-element Flux.OneHotVector{3,UInt32}:
16-
0
17-
0
15+
3-element OneHotVector(::UInt32) with eltype Bool:
16+
17+
1818
1
1919
```
2020

@@ -44,16 +44,16 @@ Flux.onecold
4444
julia> using Flux: onehotbatch
4545
4646
julia> onehotbatch([:b, :a, :b], [:a, :b, :c])
47-
3×3 Flux.OneHotArray{3,2,Vector{UInt32}}:
48-
0 1 0
49-
1 0 1
50-
0 0 0
51-
52-
julia> onecold(ans, [:a, :b, :c])
53-
3-element Vector{Symbol}:
54-
:b
55-
:a
56-
:b
47+
3×3 OneHotMatrix(::Vector{UInt32}) with eltype Bool:
48+
1
49+
1 1
50+
⋅ ⋅ ⋅
51+
52+
julia> onecold(ans, [:a, :b, :c])
53+
3-element Vector{Symbol}:
54+
:b
55+
:a
56+
:b
5757
```
5858

5959
Note that these operations returned `OneHotVector` and `OneHotMatrix` rather than `Array`s. `OneHotVector`s behave like normal vectors but avoid any unnecessary cost compared to using an integer index directly. For example, multiplying a matrix with a one-hot vector simply slices out the relevant row of the matrix under the hood.

0 commit comments

Comments
 (0)