pytorch one-hot转数组

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/jacke121/article/details/83039764

检索不为0的:

import torch

x = torch.Tensor([0,1,10,0,1])
print( torch.nonzero(x).squeeze())

猜你喜欢

转载自blog.csdn.net/jacke121/article/details/83039764
今日推荐