a = torch.randn(3, 5)
print(a)
b = torch.ones(3, 5)
print(b)
c = torch.where(a > 0, a, b)
print(c)
d = torch.randn(1,2)
d = d.long()
e = c[d]
print(e)
合并两个tensor,a>0的地方取a值,否则取b值;e的向量前2位为d的长度,最后一位为a的最后一位。torch.where(condition, x, y):condition:判断条件 x:若满足条件,则取x中元素 y:若不满足条件,则取y中元素