matchzoo.modules.matching_tensor

Matching Tensor module.

Module Contents

class matchzoo.modules.matching_tensor.MatchingTensor(matching_dim: int, channels: int = 4, normalize: bool = True, init_diag: bool = True)

Bases: torch.nn.Module

Module that captures the basic interactions between two tensors.

Parameters:
  • matching_dims – Word dimension of two interaction texts.
  • channels – Number of word interaction tensor channels.
  • normalize – Whether to L2-normalize samples along the dot product axis before taking the dot product. If set to True, then the output of the dot product is the cosine proximity between the two samples.
  • init_diag – Whether to initialize the diagonal elements of the matrix.

Examples

>>> import matchzoo as mz
>>> matching_dim = 5
>>> matching_tensor = mz.modules.MatchingTensor(
...    matching_dim,
...    channels=4,
...    normalize=True,
...    init_diag=True
... )
forward(self, x, y)

The computation logic of MatchingTensor.

Parameters:inputs – two input tensors.