PyTorch是一个非常有可能改变深度学习领域前景的Python库。我尝试使用了几星期PyTorch,然后被它的易用性所震惊,在我使用过的各种深度学习库中,PyTorch是最灵活、最容易掌握的。
一、where
1)torch.where(condition, x, y) # condition是条件,满足条件就返回x,不满足就返回y

2)特点,相比for循环的优点是:可以布置在GPU上运行

二、gather
1)官方解释:根据指定的维度和索引值来筛选值

2)举例

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。