Hi all,
I want to implement Gram Matrix of a tensor with shape
(batch_size, channel_size, patch_size, height, width)
We can calculate it only by this code in numpy A @ A.T.
My question is why in neural style transfer tutorial 72, first we convert our matrix into 2D matrix, then use .mm function to multiply it by its transpose?
def gram_matrix(input):
    a, b, c, d = input.size()  # a=batch size(=1)
    # b=number of feature maps
    # (c,d)=dimensions of a f. map (N=c*d)

    features = input.view(a * b, c * d)  # resise F_XL into \hat F_XL

    G = torch.mm(features, features.t())  # compute the gram product

    # we 'normalize' the values of the gram matrix
    # by dividing by the number of element in each feature maps.
    return G.div(a * b * c * d)

Is there any optimization consideration or anything else?
Bests