I see that there are no modules in nn
to e.g. add a constant. I understand that it is easy to do in an imperative way, but it feels like there should also be a way to do simple arithmetics within nn.Sequential
.
In LuaTorch, there were nn.Add/nn.Mul, etc. Do I miss some obvious way to define a state-less nn.Module
in one line? Something like
nn.Sequential(
...,
nn.ModuleFromFunction(lambda x : x + 2),
)
to add a constant 2 to the result of the previous operation, where the function passed to nn.ModuleFromFunction
implements nn.Module.forward()
. Or is it not a common use case?