quantlab.model.torch_data.CrossSectionDataset#
- class quantlab.model.torch_data.CrossSectionDataset(panel, bars, window_bars, training)[source]#
Bases:
DatasetOne item per bar: the bar’s whole cross-section with its windows.
Item
iis aBatchfor one bart: every symbol present att, each with its lastwindow_barsbars, soxis[S_t, N, F]. Symbols without a valid training target stay inxas context and are only masked out of the loss. In training the dataset holds the given bars with at least one valid target; in evaluation it holds every given bar with at least one present symbol, so prediction covers every present cell.Items vary in size, so batch them with
batch_size=None(theTorchModeldefault): one bar per step.- Parameters:
- panelTrainingPanel
The panel to read.
- barsarray-like of int
Positions of the bars on the panel’s time axis.
- window_barsint
N, bars per window; at least 1.
- trainingbool
Whether the dataset feeds training steps.
- Raises:
- ValueError
If
window_barsis below 1.
Examples
>>> dataset = CrossSectionDataset(panel, bars=[1, 2], window_bars=2, training=False) >>> len(dataset), dataset[0].x.shape, dataset[0].where[0].tolist() (2, torch.Size([2, 2, 1]), [1, 1])