国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

深入淺出Pytorch函數(shù)——torch.tensor

這篇具有很好參考價(jià)值的文章主要介紹了深入淺出Pytorch函數(shù)——torch.tensor。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

分類目錄:《深入淺出Pytorch函數(shù)》總目錄
相關(guān)文章:
· 深入淺出TensorFlow2函數(shù)——tf.constant
· 深入淺出Pytorch函數(shù)——torch.tensor
· 深入淺出Pytorch函數(shù)——torch.as_tensor
· 深入淺出Pytorch函數(shù)——torch.Tensor
· 深入淺出PaddlePaddle函數(shù)——paddle.to_tensor


基于data構(gòu)建一個(gè)沒有梯度歷史的張量(葉張量)。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-443317.html

語(yǔ)法
torch.tensor(data, *, dtype=None, device=None, requires_grad=False, pin_memory=False)
參數(shù)
  • data:張量的初始數(shù)據(jù)。可以是列表、元組、numpy.ndarray、標(biāo)量及其他類型
  • dtype:[torch.dtype, 可選] 返回所需張量的數(shù)據(jù)類型。如果為None,則推斷數(shù)據(jù)類型數(shù)據(jù)
  • device:[torch.device, 可選] 構(gòu)造張量的設(shè)備。如果為None且數(shù)據(jù)是張量,則使用數(shù)據(jù)的設(shè)備。如果為None且數(shù)據(jù)不是張量,則結(jié)果張量在CPU上構(gòu)建。
  • requires_grad:[bool, 可選] 標(biāo)識(shí)自動(dòng)微分是否記錄返回張量的操作,默認(rèn)為False
  • pin_memory:[bool, 可選] 如果設(shè)置,返回的張量將被分配到固定內(nèi)存中。僅適用于CPU張量。默認(rèn)為False
實(shí)例
>>> torch.tensor([[0.1, 1.2], [2.2, 3.1], [4.9, 5.2]])
tensor([[ 0.1000,  1.2000],
        [ 2.2000,  3.1000],
        [ 4.9000,  5.2000]])

>>> torch.tensor([0, 1])  # Type inference on data
tensor([ 0,  1])

>>> torch.tensor([[0.11111, 0.222222, 0.3333333]],
...              dtype=torch.float64,
...              device=torch.device('cuda:0'))  # creates a double tensor on a CUDA device
tensor([[ 0.1111,  0.2222,  0.3333]], dtype=torch.float64, device='cuda:0')

>>> torch.tensor(3.14159)  # Create a zero-dimensional (scalar) tensor
tensor(3.1416)

>>> torch.tensor([])  # Create an empty tensor (of size (0,))
tensor([])

到了這里,關(guān)于深入淺出Pytorch函數(shù)——torch.tensor的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 深入淺出Pytorch函數(shù)——torch.arange

    分類目錄:《深入淺出Pytorch函數(shù)》總目錄 相關(guān)文章: · 深入淺出TensorFlow2函數(shù)——tf.range · 深入淺出Pytorch函數(shù)——torch.arange · 深入淺出PaddlePaddle函數(shù)——paddle.arange 語(yǔ)法 當(dāng) dtype 表示浮點(diǎn)類型時(shí),為了避免浮點(diǎn)計(jì)算誤差,建議給 end 加上一個(gè)極小值 epsilon ,使邊界可以更加明

    2024年02月04日
    瀏覽(100)
  • 深入淺出Pytorch函數(shù)——torch.squeeze

    分類目錄:《深入淺出Pytorch函數(shù)》總目錄 相關(guān)文章: · 深入淺出Pytorch函數(shù)——torch.squeeze · 深入淺出Pytorch函數(shù)——torch.unsqueeze 將輸入張量形狀為1的維度去除并返回。比如輸入向量的形狀為 A × 1 × B × 1 × C × 1 × D Atimes1times Btimes1times Ctimes1times D A × 1 × B × 1 × C × 1 ×

    2024年02月16日
    瀏覽(90)
  • 深入淺出Pytorch函數(shù)——torch.maximum

    分類目錄:《深入淺出Pytorch函數(shù)》總目錄 相關(guān)文章: · 深入淺出Pytorch函數(shù)——torch.max · 深入淺出Pytorch函數(shù)——torch.maximum 計(jì)算 input 和 other 的元素最大值。 語(yǔ)法 參數(shù) input :[ Tensor ] 輸入張量 other :[ Tensor ] 輸入的第二個(gè)張量 實(shí)例

    2024年02月15日
    瀏覽(95)
  • 深入淺出Pytorch函數(shù)——torch.max

    分類目錄:《深入淺出Pytorch函數(shù)》總目錄 相關(guān)文章: · 深入淺出Pytorch函數(shù)——torch.max · 深入淺出Pytorch函數(shù)——torch.maximum torch.max 有三種輸入形式,根據(jù)其輸入形式及參數(shù)的不同有下列三種返回形式: torch.max(input) :返回輸入張量所有元素的最大值。 torch.max(input, dim, keep

    2024年02月15日
    瀏覽(92)
  • 深入淺出Pytorch函數(shù)——torch.zeros

    分類目錄:《深入淺出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 · 深

    2024年02月07日
    瀏覽(97)
  • 深入淺出Pytorch函數(shù)——torch.ones

    分類目錄:《深入淺出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 · 深

    2023年04月26日
    瀏覽(125)
  • 深入淺出Pytorch函數(shù)——torch.exp

    分類目錄:《深入淺出Pytorch函數(shù)》總目錄 相關(guān)文章: · 深入淺出TensorFlow2函數(shù)——tf.exp · 深入淺出TensorFlow2函數(shù)——tf.math.exp · 深入淺出Pytorch函數(shù)——torch.exp · 深入淺出PaddlePaddle函數(shù)——paddle.exp 對(duì)輸入 input 逐元素進(jìn)行以自然數(shù) e e e 為底指數(shù)運(yùn)算。 語(yǔ)法 參數(shù) input :[ Te

    2024年02月11日
    瀏覽(90)
  • 深入淺出Pytorch函數(shù)——torch.t

    分類目錄:《深入淺出Pytorch函數(shù)》總目錄 相關(guān)文章: · 深入淺出TensorFlow2函數(shù)——tf.transpose · 深入淺出Pytorch函數(shù)——torch.t · 深入淺出Pytorch函數(shù)——torch.transpose · 深入淺出PaddlePaddle函數(shù)——paddle.transpose 語(yǔ)法 參數(shù) input : [Tensor] 輸入的張量。 返回值 被轉(zhuǎn)置的張量。 實(shí)例

    2024年02月11日
    瀏覽(91)
  • 深入淺出PyTorch函數(shù)torch.rand與torch.randn

    深入淺出PyTorch函數(shù)torch.rand與torch.randn

    torch.rand 和 torch.randn 都是PyTorch中用于生成隨機(jī)張量的函數(shù),但它們生成隨機(jī)數(shù)的方式有所不同。 torch.rand 生成在區(qū)間 [0, 1) 內(nèi)均勻分布的隨機(jī)數(shù)。 size 參數(shù)是一個(gè)表示所需張量形狀的元組或整數(shù)??梢陨扇魏涡螤畹碾S機(jī)張量。 torch.randn 生成從標(biāo)準(zhǔn)正態(tài)分布(均值為0,標(biāo)準(zhǔn)

    2024年02月09日
    瀏覽(102)
  • 深入淺出Pytorch函數(shù)——torch.nn.Linear

    分類目錄:《深入淺出Pytorch函數(shù)》總目錄 對(duì)輸入數(shù)據(jù)做線性變換 y = x A T + b y=xA^T+b y = x A T + b 語(yǔ)法 參數(shù) in_features :[ int ] 每個(gè)輸入樣本的大小 out_features :[ int ] 每個(gè)輸出樣本的大小 bias :[ bool ] 若設(shè)置為 False ,則該層不會(huì)學(xué)習(xí)偏置項(xiàng)目,默認(rèn)值為 True 變量形狀 輸入變量:

    2024年02月12日
    瀏覽(94)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包