欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

Python中is_tensor()方法如何使用

這篇文章將為大家詳細(xì)講解有關(guān)Python中is_tensor()方法如何使用,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個(gè)參考,希望大家閱讀完這篇文章后對(duì)相關(guān)知識(shí)有一定的了解。

創(chuàng)新互聯(lián)建站是專業(yè)的柘城網(wǎng)站建設(shè)公司,柘城接單;提供成都網(wǎng)站制作、成都做網(wǎng)站,網(wǎng)頁設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行柘城網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來合作!

PyTorch torch.is_tensor()如果傳遞的對(duì)象是PyTorch張量,則方法返回True。

用法:

torch.is_tensor(object)

參數(shù)

  • object:這是要測(cè)試的輸入張量。

返回:它返回True或False。

讓我們借助幾個(gè)示例來了解這個(gè)概念:
范例1:
 

# Importing the PyTorch library  
import torch  
    
# A constant tensor of size n 
a = torch.FloatTensor([1, 4, 6, 9]) 
print(a) 
  
# Applying the is_tensor function and  
# storing the result in 'out' 
out = torch.is_tensor(a) 
print(out)

輸出:

1
4
6
9
[torch.FloatTensor of size 4]
True

范例2:

# Importing the PyTorch library  
import torch  
    
# A constant tensor of size n 
a = torch.randn(4, 6) 
print(a) 
  
# Applying the is_tensor function and  
# storing the result in 'out' 
out = torch.is_tensor(a) 
print(out)

輸出:

 0.7491 -1.5987 -0.9733  0.0436 -0.3093  2.0007
 0.5679 -0.0092 -0.2573  0.9173  2.9849 -2.0159
-1.9215 -0.9131 -0.8244  0.4160 -0.3855  0.7033
 1.7367 -1.1454 -1.4369 -0.9856 -0.9076  0.6267
[torch.FloatTensor of size 4x6]
True

關(guān)于Python中is_tensor()方法如何使用就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。

網(wǎng)站名稱:Python中is_tensor()方法如何使用
網(wǎng)頁URL:http://chinadenli.net/article36/gdoisg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供、App開發(fā)微信小程序、營銷型網(wǎng)站建設(shè)網(wǎng)站導(dǎo)航、網(wǎng)站設(shè)計(jì)公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)