日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

pytorch torch.Tensor.new_ones()(返回一个与size大小相同的用1填充的张量。 默认返回的Tensor具有与此张量相同的torch.dtype和torch.device)

發布時間:2025/3/20 39 豆豆

from https://pytorch.org/docs/1.1.0/tensors.html?highlight=new_ones#torch.Tensor.new_ones

new_ones(size, dtype=None, device=None, requires_grad=False) → Tensor Returns a Tensor of size size filled with 1. By default, the returned Tensor has the same torch.dtype and torch.device as this tensor. 返回一個與size大小相同的用1填充的張量。 默認情況下,返回的Tensor具有與此張量相同的torch.dtype和torch.device。

Parameters

size (int...) – a list, tuple, or torch.Size of integers defining the shape of the output tensor. 一個列表,元組或定義輸出張量形狀的整數的torch.Sizedtype (torch.dtype, optional) – the desired type of returned tensor. Default: if None, same torch.dtype as this tensor. 所需的返回張量類型。 默認值:如果為None,則與此張量相同的torch.dtype。device (torch.device, optional) – the desired device of returned tensor. Default: if None, same torch.device as this tensor. 返回張量的所需設備。 默認值:如果為None,則與此張量相同的torch.device。requires_grad (bool, optional) – If autograd should record operations on the returned tensor. Default: False. 如果自動求導應該在返回的張量上記錄操作。 默認值:False

Example:

>>> tensor = torch.tensor((), dtype=torch.int32) >>> tensor.new_ones((2, 3)) tensor([[ 1, 1, 1],[ 1, 1, 1]], dtype=torch.int32)

總結

以上是生活随笔為你收集整理的pytorch torch.Tensor.new_ones()(返回一个与size大小相同的用1填充的张量。 默认返回的Tensor具有与此张量相同的torch.dtype和torch.device)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。