当前位置:网站首页>torch. New usage of where (old but ignored usage)

torch. New usage of where (old but ignored usage)

2022-06-12 18:14:00 znsoft

torch.where(condition) → tuple of LongTensor

torch.where(condition) is identical to torch.nonzero(condition, as_tuple=True).

Usually , We all I'll use it like this torch.where function :

torch.where(condition, x, y)

But actually torch.where There is also the usage as shown in the heading , return tuple.

tuple Medium is condition Of qualified values in index.

such as

a=[1,2,3,4,5]

torch.where(a>3)

return ( 3,4)

原网站

版权声明
本文为[znsoft]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/163/202206121804113318.html