torch_blue.vi.VITransformerDecoderLayer
- class torch_blue.vi.VITransformerDecoderLayer(d_model: int, nhead: int, dim_feedforward: int = 512, activation: torch.nn.Module = ReLU(), layer_norm_eps: float = 1e-05, norm_first: bool = False, batch_first: bool = True, bias: bool = True, variational_distribution: Distribution = MeanFieldNormal(), prior: Distribution = MeanFieldNormal(), rescale_prior: bool = True, kaiming_initialization: bool = True, prior_initialization: bool = False, return_log_probs: bool = True, device: torch.device | None = None, dtype: torch.dtype | None = None)
Bases:
torch_blue.vi.base.VIModuleTransformerDecoderLayer is made up of self-attn, multi-head-attn and feedforward network.
Equivalent of
nn.TransformerDecoderLayerwith variational inference. See its documentation for usage.This does not support the
dropoutargument. In addition to all other arguments, this class acceptsVIkwargs.- Parameters:
- return_log_probs = True
Set whether the module returns log probabilities.
Log probabilities are required for most standard losses.
- Returns:
Whether the module returns log probabilities.
- Return type:
bool
- forward(tgt: torch.Tensor, memory: torch.Tensor, tgt_mask: torch.Tensor | None = None, memory_mask: torch.Tensor | None = None, tgt_key_padding_mask: torch.Tensor | None = None, memory_key_padding_mask: torch.Tensor | None = None, tgt_is_causal: bool = False, memory_is_causal: bool = False) torch.Tensor
Pass the input through the decoder layer.
See documentation of
nn.TranformerDecoderLayerfor details.This implementation also currently does not support the torch fastpath.