Custom Layer in Lux.jl

So the syntax (x::Type)(y) = ... means if we have a variable a of type Type and write a(b) this method would be called with a bound to x and b bound to y.
One could create a similar effect by defining somename(x::Type, y) and calling it with somename(a, b), so this is just syntax to skip having this extra function name and make the type callable by itself.

In your example you have the variable model that is of type LuxLinear, so when you write model(x, ps, st) you call the method (l::LuxLinear)(x, ps, st) with model bound to l.

1 Like