ConcatProjectionCombination

class ConcatProjectionCombination(input_dims: ~collections.abc.Sequence[int], output_dim: int | None = None, bias: bool = True, dropout: float = 0.0, activation: str | ~torch.nn.modules.module.Module | type[~torch.nn.modules.module.Module] | None = <class 'torch.nn.modules.linear.Identity'>, activation_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None)[source]

Bases: ConcatCombination

Combine representations by concatenation follow by a linear projection and activation.

Initialize the combination.

Parameters:
  • input_dims (Sequence[int]) – the input dimensions

  • output_dim (int | None) – the output dimension. Defaults to the first input dimension

  • bias (bool) – whether to add a bias term in between the linear projection and the activation

  • dropout (float) – dropout to use before the activation

  • activation (str | Module | type[Module] | None) – the activation, or a hint thereof

  • activation_kwargs (Mapping[str, Any] | None) – additional keyword-based parameters used to instantiate the activation

Raises:

ValueError – if input_dims is empty

Methods Summary

forward(xs)

Combine a sequence of individual representations.

Methods Documentation

forward(xs: Sequence[Tensor]) Tensor[source]

Combine a sequence of individual representations.

Parameters:

xs (Sequence[Tensor]) – shape: (*batch_dims, *input_dims_i) the individual representations

Returns:

shape: (*batch_dims, *output_dims) a combined representation

Return type:

Tensor