quantlab.model.predefined.master.Gate#

class quantlab.model.predefined.master.Gate(d_input, d_output, beta)[source]#

Bases: Module

F · softmax(Linear(market) / beta): weights for F features that sum to F.

Examples

>>> weights = Gate(2, 5, beta=5.0)(torch.randn(3, 2))
>>> weights.shape, [round(w, 4) for w in weights.sum(dim=-1).tolist()]
(torch.Size([3, 5]), [5.0, 5.0, 5.0])
forward(market)[source]#

Map [S_t, G] market features to [S_t, F] feature weights.

Examples

>>> Gate(2, 5, beta=5.0).forward(torch.zeros(1, 2)).shape
torch.Size([1, 5])