本文簡要介紹python語言中 torch.zeros
的用法。
用法:
torch.zeros(*size, *, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) → Tensor
size(詮釋...) -定義輸出張量形狀的整數序列。可以是可變數量的參數或像列表或元組這樣的集合。
out(Tensor,可選的) -輸出張量。
dtype(
torch.dtype
, 可選的) -返回張量的所需數據類型。默認值:如果None
,使用全局默認值(參見torch.set_default_tensor_type()
)。layout(
torch.layout
, 可選的) -返回張量的所需布局。默認值:torch.strided
。device(
torch.device
, 可選的) -返回張量的所需設備。默認值:如果None
,使用當前設備作為默認張量類型(參見torch.set_default_tensor_type()
)。device
將是 CPU 張量類型的 CPU 和 CUDA 張量類型的當前 CUDA 設備。requires_grad(bool,可選的) -如果 autograd 應該在返回的張量上記錄操作。默認值:
False
。
返回一個用標量值
0
填充的張量,其形狀由變量參數size
定義。例子:
>>> torch.zeros(2, 3) tensor([[ 0., 0., 0.], [ 0., 0., 0.]]) >>> torch.zeros(5) tensor([ 0., 0., 0., 0., 0.])
參數:
關鍵字參數:
相關用法
- Python PyTorch zeros_用法及代碼示例
- Python PyTorch zeros_like用法及代碼示例
- Python PyTorch zeta用法及代碼示例
- Python PyTorch frexp用法及代碼示例
- Python PyTorch jvp用法及代碼示例
- Python PyTorch cholesky用法及代碼示例
- Python PyTorch vdot用法及代碼示例
- Python PyTorch ELU用法及代碼示例
- Python PyTorch ScaledDotProduct.__init__用法及代碼示例
- Python PyTorch gumbel_softmax用法及代碼示例
- Python PyTorch get_tokenizer用法及代碼示例
- Python PyTorch saved_tensors_hooks用法及代碼示例
- Python PyTorch positive用法及代碼示例
- Python PyTorch renorm用法及代碼示例
- Python PyTorch AvgPool2d用法及代碼示例
- Python PyTorch MaxUnpool3d用法及代碼示例
- Python PyTorch Bernoulli用法及代碼示例
- Python PyTorch Tensor.unflatten用法及代碼示例
- Python PyTorch Sigmoid用法及代碼示例
- Python PyTorch Tensor.register_hook用法及代碼示例
- Python PyTorch ShardedEmbeddingBagCollection.named_parameters用法及代碼示例
- Python PyTorch sqrt用法及代碼示例
- Python PyTorch PackageImporter.id用法及代碼示例
- Python PyTorch column_stack用法及代碼示例
- Python PyTorch diag用法及代碼示例
注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torch.zeros。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。