AI學(xué)習(xí)目錄匯總
1、torch.arange
返回一維張量(一維數(shù)組),官網(wǎng)說(shuō)明,常見(jiàn)的三種用法如下文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-616070.html
輸入:torch.arange(5)
輸出:tensor([0, 1, 2, 3, 4])
輸入:torch.arange(5, 16)
輸出:tensor([ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])
輸入:torch.arange(1, 25, 2)
輸出:tensor([ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23])
2、tensor.shape、tensor.reshape
tensor.shape:查看張量的形狀
tensor.reshape:返回改變形狀后的張量,原張量不變文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-616070.html
輸入:x=torch.arange(12)
輸入:x
輸出:tensor([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
輸入:x.shape
輸出:tor
到了這里,關(guān)于【AI】《動(dòng)手學(xué)-深度學(xué)習(xí)-PyTorch版》筆記(三):PyTorch常用函數(shù)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!