分類目錄:《深入淺出Pytorch函數(shù)》總目錄
相關(guān)文章:
· 深入淺出Pytorch函數(shù)——torch.Tensor
· 深入淺出Pytorch函數(shù)——torch.ones
· 深入淺出Pytorch函數(shù)——torch.zeros
· 深入淺出Pytorch函數(shù)——torch.full
· 深入淺出Pytorch函數(shù)——torch.ones_like
· 深入淺出Pytorch函數(shù)——torch.zeros_like
· 深入淺出Pytorch函數(shù)——torch.full_like文章來源:http://www.zghlxwxcb.cn/news/detail-465774.html
語法
torch.full(size, fill_value, *, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) → Tensor
參數(shù)
-
size
:大小,定義輸出張量形狀的整數(shù)序列??梢允强勺償?shù)量的參數(shù)或集合,如:列表或元組。 -
fill_value
:填入輸出tensor
的值 -
out
:[可選,Tensor] 輸出張量 -
dtype
:[可選,torch.dtype
] 返回張量的所需數(shù)據(jù)類型。如果為None
,則使用全局默認(rèn)值(參考torch.set_default_tensor_type()
)。 -
layout
:[可選,torch.layout
] 返回張量的期望內(nèi)存布局形式,默認(rèn)為torch.strided
。 -
device
:返回張量的期望計(jì)算設(shè)備。如果為None
,使用當(dāng)前的設(shè)備(參考torch.set_default_tensor_type()
),設(shè)備將CPU用于CPU張量類型,將CUDA設(shè)備用于CUDA張量類型。 -
requires_grad
:[可選,bool
] 是否需要自動微分,默認(rèn)為False
。
返回值
返回一個每個元素都是fill_value
、形狀為size
、數(shù)據(jù)類型為dtype
的Tensor。文章來源地址http://www.zghlxwxcb.cn/news/detail-465774.html
實(shí)例
>>> torch.full((2, 3), 3.141592)
tensor([[ 3.1416, 3.1416, 3.1416],
[ 3.1416, 3.1416, 3.1416]])
到了這里,關(guān)于深入淺出Pytorch函數(shù)——torch.full的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!