Hi, I am writing a custom layer and am trying to emulate the UI of Flux layers.
In the definition of Flux’s Dense layer the Dense struct has a field weight, but this field also has a kind of alias W. How/where is this alias defined? It was not apparent to me from reading the source code.
using Flux
a = Dense(3,3)
a.W === a.weight # is true
a.W is actually getproperty(a, :W). This is not specific to Flux, but how the dot works in Julia.
Flux adds a specialization to getproperty. See @which a.W and the corresponding source file.
3 Likes
Thanks 
I found the relevant lines of code in my local install by using @which like you explained. Turns out a.W and a.b is deprecated syntax, and has been removed from master in this commit.
Old field name aliasing code
function Base.getproperty(a::Dense, s::Symbol)
if s === :W
Base.depwarn("field name dense.W is deprecated in favour of dense.weight", :Dense)
return getfield(a, :weight)
elseif s === :b
Base.depwarn("field name dense.b is deprecated in favour of dense.bias", :Dense)
return getfield(a, :bias)
end
return getfield(a, s)
end
1 Like