Hi!
Did this ever get solved? I have basically the exact same issue when trying to calculate the Gram Matrix. I’m using anomaly detection and it is pointing me to the matrix multiplication or transpose operator…
This is how I calculate the gram matrix:
def gram_matrix(activation, N, M):
    feature_map = activation.reshape((N, M))
    G = torch.mm(feature_map, feature_map.t())
    return G