Flattening

class torchjd.aggregation.Flattening(weighting)[source]

GeneralizedWeighting flattening the generalized Gramian into a square matrix, extracting a vector of weights from it using a Weighting, and returning the reshaped tensor of weights.

For instance, when applied to a generalized Gramian of shape [2, 3, 3, 2], it would flatten it into a square Gramian matrix of shape [6, 6], apply the weighting on it to get a vector of weights of shape [6], and then return this vector reshaped into a matrix of shape [2, 3].

Parameters:

weighting (Weighting[Tensor]) – The weighting to apply to the Gramian matrix.