Solved by kirk86 in post #2 
              
              
                To compute cosine similarity between two vectors x, y you need to have both vectors same size as you can see from the example in the same page you linked in your comment: 
>>> input1 = torch.randn(100, 128)
>>> input2 = torch.randn(100, 128)
>>> cos = nn.CosineSimilarity(dim)

in your case you have N…