Skip to content

Commit 46fec33

Browse files
committed
add docs for OneHot
1 parent 917ba3e commit 46fec33

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

docs/literate/preprocessing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ This library also implements some general transformations useful for getting dat
55
- [`ToEltype`](#)`(T)` converts the element type of any [`AbstractArrayItem`](#) to `T`.
66
- [`ImageToTensor`](#) converts an image to an `ArrayItem` with another dimension for the color channels
77
- [`Normalize`](#) normalizes image tensors
8+
- [`OneHot`](#) to one-hot encode multi-class masks ([`MaskMulti`](#)s)
89

src/preprocessing.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,17 @@ tensortoimage(a::AbstractArray{T, 2}) where T = colorview(Gray, a)
186186

187187
# OneHot encoding
188188

189+
"""
190+
OneHot([T = Float32])
191+
192+
One-hot encodes a `MaskMulti` with `n` classes and size `sz` into
193+
an array item of size `(sz..., n)` with element type `T`. Supports [`apply!`].
194+
195+
```julia
196+
item = MaskMulti(rand(1:4, 100, 100), 1:4)
197+
apply(OneHot(), item)
198+
```
199+
"""
189200
struct OneHot{T} <: Transform end
190201
OneHot() = OneHot{Float32}()
191202

0 commit comments

Comments
 (0)