A patch-based Transformer (LPatchTST) trained on NIFTY 50 30-minute bars
for directional signal prediction.
1import torch
2import sys
3sys.path.insert(0, ".") # ensure local modules are importable
4
5import config
6from model import LPatchTST
7
8net = LPatchTST(
9 input_mode=config.INPUT_MODE,
10 seq_len=config.LOOKBACK_WINDOW,
11 n_features=0, # set to your feature count
12 s1_bits=config.TOKENIZER_S1_BITS,
13 s2_bits=config.TOKENIZER_S2_BITS,
14 d_model=config.D_MODEL,
15 patch_len=config.PATCH_LEN,
16 stride=config.STRIDE,
17 n_heads=config.N_HEADS,
18 n_layers=config.N_LAYERS,
19 lstm_layers=config.LSTM_LAYERS,
20 dropout=config.FINETUNE_DROPOUT,
21 aggregation=config.AGGREGATION_MODE,
22)
23state = torch.load("best_model_lpatchtst.pth", map_location="cpu")
24net.load_state_dict(state)
25net.eval()