generalized linear and nonlinear layers