pytorch随笔-6
生活随笔
收集整理的這篇文章主要介紹了
pytorch随笔-6
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
是否為復(fù)數(shù),tensor大小 。
#/usr/bin/env python3 # -*- coding: utf-8 -*-import torchx_data = torch.tensor([[12 + 0.2j],[6 - 1.2j]]) print(f"Tensor: \n {x_data} \n") print(f"is_complex: \n {torch.is_complex(x_data)} \n") print(f"shape: \n {x_data.shape} \n") Tensor: tensor([[12.+0.2000j],[ 6.-1.2000j]]) is_complex: True shape: torch.Size([2, 1])是否為浮點(diǎn)數(shù),tensor大小 。
#/usr/bin/env python3 # -*- coding: utf-8 -*-import torchx_data = torch.tensor([[12.2],[62]]) print(f"Tensor: \n {x_data} \n") print(f"is_floating_point: \n {torch.is_floating_point(x_data)} \n") print(f"shape: \n {x_data.shape} \n") Tensor: tensor([[12.2000],[62.0000]]) is_floating_point: True shape: torch.Size([2, 1])下面這類屬于0值 torch。
torch.tensor([0.])
torch.tensor([0])
torch.tensor([False])
而torch.is_nonzero檢測(cè)是否非0。
torch.is_nonzero參數(shù)必須是單個(gè)元素
總結(jié)
以上是生活随笔為你收集整理的pytorch随笔-6的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PyTorch随笔-5
- 下一篇: 谈谈对ThreadLocal的理解?(基