quantlab.model.torch_training.drop_extreme#
- quantlab.model.torch_training.drop_extreme(y, fraction, column=0)[source]#
Return the rows kept after dropping both tails of one label column.
With
k = int(fraction * n), n the number of finite labels incolumn, the k smallest and the k largest are dropped (ties broken by position), as MASTER does in training. Rows with a NaN label are kept.- Parameters:
- ytorch.Tensor
One bar’s labels,
[S_t, L].- fractionfloat
Share dropped from each tail, in
[0, 0.5).- columnint, default 0
The label column that decides.
- Returns:
- torch.Tensor
[S_t]booleans, True for the rows kept.
- Raises:
- ValueError
If
fractionis outside[0, 0.5).
Examples
>>> y = torch.tensor([[5.0], [1.0], [float("nan")], [3.0], [2.0], [4.0]]) >>> drop_extreme(y, 0.2) tensor([False, False, True, True, True, True])