import torch upper_tri = torch.ones(rol, col).triu() Eg: >> mat = torch.ones(3, 3).triu() >> print(mat) tensor([[1., 1., 1.], [0., 1., 1.], [0., 0., 1.]])
torch.triu()
了吗? - JoshVarty