【文件属性】:
文件名称:详解PyTorch中Tensor的高阶操作
文件大小:47KB
文件格式:PDF
更新时间:2021-01-20 05:36:56
c ns OR
条件选取:torch.where(condition, x, y) → Tensor
返回从 x 或 y 中选择元素的张量,取决于 condition
操作定义:
举个例子:
>>> import torch
>>> c = randn(2, 3)
>>> c
tensor([[ 0.0309, -1.5993, 0.1986],
[-0.0699, -2.7813, -1.1828]])
>>> a = torch.ones(2, 3)
>>> a
tensor([[1., 1., 1.],
[1., 1., 1.]])
>>> b = torch.zeros(2,