quantlab.model.predefined.mlp.MLPNet#
- class quantlab.model.predefined.mlp.MLPNet(num_features, num_labels, layers=(256,), act='LeakyReLU')[source]#
Bases:
ModuleQlib’s
Net: dropout,Linear+BatchNorm1d+LeakyReLUlayers, dropout,Linear.The input is each sample’s latest bar. Input and output dropout are 0.05, the activation is
LeakyReLU(0.1)(or SiLU), and every linear weight starts Kaiming-normal. The parameter names are Qlib’s (dnn_layers), so a Qlib state dict loads into a one-label net.- Parameters:
- num_featuresint
Features,
F.- num_labelsint
Outputs per sample,
L; Qlib’s model has one.- layerstuple of int, default (256,)
Hidden widths.
- act{“LeakyReLU”, “SiLU”}, default “LeakyReLU”
The activation.
- Raises:
- ValueError
If
actis neither"LeakyReLU"nor"SiLU".
Examples
>>> net = MLPNet(num_features=4, num_labels=2, layers=(8,)).eval() >>> net(torch.randn(5, 3, 4)).shape torch.Size([5, 2])