-
Notifications
You must be signed in to change notification settings - Fork 63
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
Documentation should emphasize calling LuxCore.apply
#1160
Comments
it calls it here: Lux.jl/src/layers/containers.jl Line 183 in 8792097
|
Right, but it's only calling it for the child layers not for |
The |
If |
overloading |
Ok, here is an MWE, albeit a little contrived: using LinearAlgebra, Random, Statistics
using CUDA
using Lux
struct InputType{T<:AbstractMatrix}
components::NTuple{2,T}
end
function Lux.apply(l::Lux.AbstractLuxLayer, x::InputType, θ, ψ::NamedTuple)
l(x.components, θ, ψ)
end
function main()
l1 = Parallel(vcat, Dense(2=>2), Dense(2=>2))
(θ, ψ) = Lux.setup(Xoshiro(999), l1)
X = InputType((randn(Float32, 2,4), randn(Float32, 2,4)))
(y, ψ′) = l1(X, θ, ψ)
end Calling
I would expect |
right because you are calling I probably see the source of confusion. xt = ArrayAndTime(x, 10.0f0)
model(xt, ps, st)[1] should be rewritten as |
Yeah, I'm definitely confused about where to use |
Yeah, generally it doesn't matter too much (except in situations like this). But using I will mark this as a documentation issue. We need to emphasize the downsides of not using |
LuxCore.apply
The
Parallel
layer never callsLux.apply
, but only calls its own methodLux.applyparallel
. The problem with this is that if you try to overload methods ofapply
to implement your own input types as described here,Parallel
will just completely ignore it.I would suggest keeping
applyparallel
as is but first adding an extra indirection viaapply
to the call toParallel
.The text was updated successfully, but these errors were encountered: