Based on the posted code I assume you want to calculate the cosine similarity between my_embedding and another tensor.
Since my_embedding is a 1-dimensional tensor, using nn.CosineSimilarity(dim=1) won’t work and you could try to use dim=0 or make sure that pic_vector* have at least 2 dimensions.