其他分享
首页 > 其他分享> > Code Review for PyTorch -- Embedding

Code Review for PyTorch -- Embedding

作者:互联网

# 1. An Embedding module containing 7 tensors of size 3
embedding = nn.Embedding(7, 3)
# A batch of 2 samples of 4 indices each
input = torch.LongTensor([[1, 2, 4, 5],
                          [4, 3, 2, 6]])  # 2 x 4
print(embedding(input).size())  # 2 x 4 x 3

标签:containing,Code,Embedding,--,Review,embedding,input,size
来源: https://www.cnblogs.com/hondy-ji/p/15865876.html