新聞中心
這篇文章主要介紹“Python torch.tensor()的簡單實用方法是什么”,在日常操作中,相信很多人在Python torch.tensor()的簡單實用方法是什么問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”Python torch.tensor()的簡單實用方法是什么”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!
我們提供的服務(wù)有:成都網(wǎng)站設(shè)計、網(wǎng)站制作、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、清苑ssl等。為千余家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的清苑網(wǎng)站制作公司
代碼實驗展示:
Microsoft Windows [版本 10.0.18363.1256](c) 2019 Microsoft Corporation。保留所有權(quán)利。 C:\Users\chenxuqi>conda activate ssd4pytorch2_2_0(ssd4pytorch2_2_0) C:\Users\chenxuqi>python Python 3.7.7 (default, May 6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32 Type "help", "copyright", "credits" or "license" for more information.>>> import torch>>> torch.tensor([[0.1, 1.2], [2.2, 3.1], [4.9, 5.2]]) # 從列表接收數(shù)據(jù)tensor([[0.1000, 1.2000],[2.2000, 3.1000],[4.9000, 5.2000]])>>>>>> torch.tensor([0, 1]) # Type inference on data 從列表中的數(shù)據(jù)類型推斷出所要使用的類型tensor([0, 1])>>>>>>>>> torch.tensor([[0.11111, 0.222222, 0.3333333]],... dtype=torch.float64,... device=torch.device('cuda:0')) # creates a torch.cuda.DoubleTensortensor([[0.1111, 0.2222, 0.3333]], device='cuda:0', dtype=torch.float64)>>>>>>>>> torch.tensor(3.14159) # Create a scalar (zero-dimensional tensor)tensor(3.1416)>>> # 創(chuàng)建一個標(biāo)量>>>>>> torch.tensor([]) # Create an empty tensor (of size (0,))tensor([])>>>>>>>>> print(torch.__version__)1.2.0+cu92>>> print(torch.cuda.is_available())True>>>>>>
到此,關(guān)于“Python torch.tensor()的簡單實用方法是什么”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
本文標(biāo)題:Pythontorch.tensor()的簡單實用方法是什么
鏈接地址:http://fisionsoft.com.cn/article/pjssij.html