[:, :,None]和unsqueeze

masked_position = torch.unsqueeze(masked_position, 2)和
masked_position = masked_position[:, :,None] 等价。

masked_position = torch.unsqueeze(masked_position, 2)
masked_position = masked_position[:, :,None]

你可能感兴趣的:(Python,Pytorch,NLP,深度学习,人工智能)