quantlab.model.predefined.transformer.LocalformerNet#
- class quantlab.model.predefined.transformer.LocalformerNet(num_features, num_labels, d_model=64, nhead=2, num_layers=2, dropout=0.0)[source]#
Bases:
ModuleQlib’s Localformer (
pytorch_localformer_ts.py) with an output of any width.TransformerNetwithLocalformerEncoderin place of PyTorch’s encoder and a GRU ofnum_layerslayers and widthDafter it;Linear(D, L)maps the GRU’s last bar to the output. The parameter names are Qlib’s, so a Qlib state dict loads into a one-label net.- Parameters:
- num_features, num_labels, d_model, nhead, num_layers, dropout
As
TransformerNet;dropoutalso applies between GRU layers.
Examples
>>> net = LocalformerNet(num_features=4, num_labels=2, d_model=8) >>> net(torch.randn(5, 3, 4)).shape torch.Size([5, 2])