"对 PyTorch 张量意味着什么?-6ren"> "对 PyTorch 张量意味着什么?-我有一个张量 it 定义为: import torch it = torch.tensor([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], device='cuda:-6ren">
gpt4 book ai didi

pytorch - "greater than"运算符 ">"对 PyTorch 张量意味着什么?

转载 作者:行者123 更新时间:2023-12-05 00:48:10 26 4
gpt4 key购买 nike

我有一个张量 it 定义为:

import torch
it = torch.tensor([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], device='cuda:0')

根据这个定义,it > 0 是什么意思?

最佳答案

使用 >运算符与使用 torch.gt() 相同功能。

换句话说,

it > 0

一样
torch.gt(it, 0)

它返回一个 ByteTensor ( bool 张量)相同的shape作为 it在哪里 out[i]如果 it[i] > 0 为真否则为 False。

关于pytorch - "greater than"运算符 ">"对 PyTorch 张量意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52868102/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com