You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Multiplication of OneHotMatrix by dense layer could be more optimized, e.g. by
using LinearAlgebra
function Base.:*(A::AbstractMatrix, B::Flux.OneHotMatrix)
m =size(A,1)
Y =similar(A, m, size(B,2))
for (j,ohv) inenumerate(B.data)
ix = ohv.ix
for i in1:m
@inbounds Y[i,j] = A[i,ix]
endend
Y
endfunction Base.:*(A::AbstractMatrix, B::Adjoint{Bool,<: Flux.OneHotMatrix})
m =size(A,1)
Y =similar(A, m, size(B,2))
Y .=0
BT = B'for (j,ohv) inenumerate(BT.data)
ix = ohv.ix
for i in1:m
@inbounds Y[i,ix] += A[i,j]
endend
Y
end