Closed
Description
Definition: Functional means that the layer / op does not have trainable parameters.
Examples:
tanh
,sigmoid
etc, i.e. all math ops. RETURNN:ActivationLayer
dot
/matmul
/einsum
. RETURNN:DotLayer
split
. RETURNN:SplitLayer
Instead of writing Activation(activation="tanh")(x)
, one should be able to write simply tanh(x)
.
Instead of Dot(...)(x, y)
, one should be able to write dot(x, y, ...)
or so. (Or maybe using a more einsum-like API.)
Instead of Split(...)(x)
, split(x, ...)
.
Similar as in the PyTorch functional API.
The naming convention would be to start with lowercase letter, unlike modules which start with upper case.
Also, modules are classes, and need to be initiated. The functional API would just behave like functions.
Related are also the elemwise ops on a LayerRef
, such as +
, ==
etc.
Some open questions:
- Where to define? Namescope?
- How far automatically generated?
- E.g. we could extend the current layer generation code, to automatically put layers without params into the functional namescope.
- Still we additionally want to manually/explicitly define some functions, e.g.
einsum
/dot
. Alsotanh
etc need to be explicit.
- Should we have always both variants, like
Sigmoid
as a module, andsigmoid
as a function?- PyTorch has this for some functions. But not always.
- Flax only has the functional variant when some op is purely functional.
Metadata
Metadata
Assignees
Labels
No labels