struct Mlp {
struct Vec<&FloatTensor> params;
unsigned long nLayers;
unsigned long inDim;
unsigned long outDim;
int act;
int outAct;
}inDim -> hidden (x hiddenLayers) -> outDim, 'act' after every hidden layer and 'outAct' after the last. hiddenLayers 0 is a single linear layer. Weights are [in, out] (transpose a PyTorch nn.Linear's), biases [out], initialized like PyTorch's nn.Linear: U(-1/sqrt(in), 1/sqrt(in)). params holds W0, b0, W1, b1, ... and every one requires grad.
Fields
Methods
[batch, inDim] -> [batch, outDim]
Parameterized (module.h): the trained tensors, and what a copy or a file carries.
= drop()
§
static struct Mlp new(
unsigned long inDim,
unsigned long hidden,
unsigned long hiddenLayers,
unsigned long outDim,
int act,
int outAct,
&Rng rng,
)source · definition