-
-
Notifications
You must be signed in to change notification settings - Fork 7
Consider shrinking list of dependencies #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The problem is that the principle thing a OneHotArray is good for is that multiplying from the left with a matrix can be done efficiently... and that calls Lines 7 to 11 in 0b49d1b
It this were moved to an extension, what should happen when I call |
Isn't that a very specific use case? I'd expect a slow fallback or error
message since these arrays aren't usually multiplied in other algorithms.
Em qua., 16 de abr. de 2025, 19:24, Michael Abbott ***@***.***>
escreveu:
… The problem is that the principle thing a OneHotArray is good for is that
multiplying from the left with a matrix can be done efficiently... and that
calls NNlib.scatter:
https://github.com/FluxML/OneHotArrays.jl/blob/0b49d1b39ad5d1ab8ed212da3ff2e180985e2591/src/linalg.jl#L7-L11
It this were moved to an extension, what should happen when I call rand(1:99,
4, 3) * onehotbatch([1,1,1], 1:3) without loading NNlib?
—
Reply to this email directly, view it on GitHub
<#50 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZQW3IOGAFZVBOLDTNDQTD2Z3KDNAVCNFSM6AAAAAB3JBNDWKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMJQHE2TANZTGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
*mcabbott* left a comment (FluxML/OneHotArrays.jl#50)
<#50 (comment)>
The problem is that the principle thing a OneHotArray is good for is that
multiplying from the left with a matrix can be done efficiently... and that
calls NNlib.scatter:
https://github.com/FluxML/OneHotArrays.jl/blob/0b49d1b39ad5d1ab8ed212da3ff2e180985e2591/src/linalg.jl#L7-L11
It this were moved to an extension, what should happen when I call rand(1:99,
4, 3) * onehotbatch([1,1,1], 1:3) without loading NNlib?
—
Reply to this email directly, view it on GitHub
<#50 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZQW3IOGAFZVBOLDTNDQTD2Z3KDNAVCNFSM6AAAAAB3JBNDWKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMJQHE2TANZTGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
In particular, I need a simple Example: using CategoricalArrays
categs = categorical([:a, :b, :b, :c, :d, :e])
onehot = onehotmatrix(categs)
onehot[1,1] # true
onehot[2,1] # false
onehot[3,1] # false
...
onehot[1,2] # false
onehot[2,2] # true
onehot[3,2] # false
...
onehot[2,1] = true # equivalent to setting categs[1] = :a Is this usage in the scope of OneHotArrays.jl? Should this In my current understanding, I think it would be better to move all functionality to CategoricalArrays.jl, then add NNlib and GPU-related packages as extensions for the fast matrix multiplication. Is there a feature in OneHotArrays.jl that justifies the existence of both packages? |
I have never used CategoricalArrays, but it seems to be backed by a julia> using CategoricalArrays, OneHotArrays
julia> categs = categorical(string.([:a, :b, :b, :c, :d, :e])); # error says Symbol no longer supported
julia> categs.refs
6-element Vector{UInt32}:
0x00000001
0x00000002
0x00000002
0x00000003
0x00000004
0x00000005
julia> oh = OneHotMatrix(categs.refs, Int(maximum(categs.refs)))
5×6 OneHotMatrix(::Vector{UInt32}) with eltype Bool:
1 ⋅ ⋅ ⋅ ⋅ ⋅
⋅ 1 1 ⋅ ⋅ ⋅
⋅ ⋅ ⋅ 1 ⋅ ⋅
⋅ ⋅ ⋅ ⋅ 1 ⋅
⋅ ⋅ ⋅ ⋅ ⋅ 1
julia> oh[1,1], oh[2,1]
(true, false)
julia> oh[2,1] = true # with PR 51 here
true
julia> categs # has been updated too
6-element CategoricalArray{String,1,UInt32}:
"b"
"b"
"b"
"c"
"d"
"e" For ...and in general this package hasn't thought carefully about when it does and doesn't preserve such references, as everything was immutable anyway. Maybe it's always true that uppercase julia> oh2 = onehotbatch(categs, unique(categs));
julia> oh2[3,1] = true;
julia> oh2
4×6 OneHotMatrix(::Vector{UInt32}) with eltype Bool:
⋅ 1 1 ⋅ ⋅ ⋅
⋅ ⋅ ⋅ 1 ⋅ ⋅
1 ⋅ ⋅ ⋅ 1 ⋅
⋅ ⋅ ⋅ ⋅ ⋅ 1
julia> categs # not changed
6-element CategoricalArray{String,1,UInt32}:
"b"
"b"
"b"
"c"
"d"
"e" That said I don't see a reason to regard this as out-of-scope. A method |
See #54 for a start on CategoricalArrays support... and having package extensions. |
This package can be useful in other contexts without GPUs nor neural nets. Could you consider moving some of the dependencies to extensions? Below is the current list of hard dependencies:
The text was updated successfully, but these errors were encountered: