https://github.com/fluxml/onehotarrays.jl
Memory efficient one-hot array encodings
https://github.com/fluxml/onehotarrays.jl
Last synced: over 1 year ago
JSON representation
Memory efficient one-hot array encodings
- Host: GitHub
- URL: https://github.com/fluxml/onehotarrays.jl
- Owner: FluxML
- License: mit
- Created: 2022-03-01T16:18:07.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-11-16T17:41:26.000Z (over 1 year ago)
- Last Synced: 2025-02-20T22:05:45.916Z (over 1 year ago)
- Language: Julia
- Homepage: https://fluxml.ai/OneHotArrays.jl/dev/
- Size: 408 KB
- Stars: 18
- Watchers: 11
- Forks: 7
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# OneHotArrays.jl
[](https://fluxml.ai/OneHotArrays.jl/dev/)
[](https://github.com/FluxML/OneHotArrays.jl/actions/workflows/CI.yml)
This package provides memory efficient one-hot array encodings.
It was originally part of [Flux.jl](https://github.com/FluxML/Flux.jl).
```julia
julia> using OneHotArrays
julia> m = onehotbatch([10, 20, 30, 10, 10], 10:10:40)
4×5 OneHotMatrix(::Vector{UInt32}) with eltype Bool:
1 ⋅ ⋅ 1 1
⋅ 1 ⋅ ⋅ ⋅
⋅ ⋅ 1 ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅
julia> dump(m)
OneHotMatrix{UInt32, 4, Vector{UInt32}}
indices: Array{UInt32}((5,)) UInt32[0x00000001, 0x00000002, 0x00000003, 0x00000001, 0x00000001]
julia> @which rand(100, 4) * m
*(A::AbstractMatrix, B::Union{OneHotArray{var"#s14", L, 1, var"N+1", I}, Base.ReshapedArray{Bool, var"N+1", <:OneHotArray{var"#s14", L, <:Any, <:Any, I}}} where {var"#s14", var"N+1", I}) where L
@ OneHotArrays ~/.julia/dev/OneHotArrays/src/linalg.jl:7
```