For a 2-dimensional tensor, I want to normalize each row vector of it. In the formula, it’s like:
I know such code below can solve easily:
embedding_norm = Torch.norm(embedding.weight.data, dim=1, keepdim=True)
But I don’t understand why the value of parameter dim = 1. I’ve read doc. where it says the value of dim must be an int to calculate vector norm, but why the number is 1 here?