quantlab.model.torch_data#
The data a TorchModel head is fed: the training panel, batches and datasets.
The base class builds one TrainingPanel per fit, or per prediction, and
hands it to the head’s _dataset hook, which returns a PyTorch
Dataset. The head’s _dataloader hook batches it with a standard
DataLoader. Every item is a Batch whose where holds the
timestamp and symbol index of each sample, so the base puts predictions
back into the [T, S, L] panel the same way for any sample shape.
Two datasets ship:
CrossSectionDataset, the default: one item per bar, holding every symbol present at that bar with its lastwindow_barsbars.SymbolSequenceDataset, Qlib style: one item per(bar, symbol)cell, the symbol’s lastwindow_barsbars as[N, F], batched by the default collation to[B, N, F], or gathered a whole batch at a time bybatch_loader.
prefetch readies a loader’s next batches on the model’s device in a
background thread, so gathering and copying the next batch overlaps the
current step.
Classes
What every step hook, |
|
One item per bar: the bar's whole cross-section with its windows. |
|
Batches of dataset positions, each an int64 tensor, for a dataset that gathers a batch at once. |
|
One item per |
|
The collected panel as torch tensors, shared by every dataset of a fit. |
Functions
A |
|
Yield |