Replies: 1 comment 1 reply
-
The fact that a) closures are structs and b) structs are callable makes me question how wide this gap really is. IMO defining a layer as a callable struct is writing a function. I would suggest (and I think you agree) that the discussion around structs/layers vs plain functions be separated from the discussion around explicit vs implicit state from the discussion around immutable vs mutable. Here's a taxonomy of sorts:
My thoughts on the above:
Also, "making functions first class" is not the same as "writing functional code." Dogmatic adherence to a functional programming paradigm (i.e. immutability always at the syntactic level, explicit state everywhere, minimal structures, lots of wrappers) will only hurt us. The beauty of Julia is that it is powerful enough to express multiple programming paradigms in the same codebase elegantly. Not everything is object-based vs functional, there is a lot in between. Let's just pick and choose. |
Beta Was this translation helpful? Give feedback.
-
This is a continuation of my comments at FluxML/Flux.jl#1301 (comment).
Part of Flux's and design philosophy is that plain functions aren't scary and you can freely use them in a model without creating a custom forward pass or using some abomination like
keras.layers.Lambda
. For this reason however, most Flux layers are layers in the first place because they require more than can be provided by a stateless function. This usually means holding parameters or other state that is required during the forward/backwards pass. Note that I would also consider closures to fit this criteria as well given how they are represented in Julia.Beta Was this translation helpful? Give feedback.
All reactions