本篇內(nèi)容介紹了“torch.equal函數(shù)怎么使用”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠?qū)W有所成!
創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供肥鄉(xiāng)網(wǎng)站建設、肥鄉(xiāng)做網(wǎng)站、肥鄉(xiāng)網(wǎng)站設計、肥鄉(xiāng)網(wǎng)站制作等企業(yè)網(wǎng)站建設、網(wǎng)頁設計與制作、肥鄉(xiāng)企業(yè)網(wǎng)站模板建站服務,十余年肥鄉(xiāng)做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡服務。
代碼實驗:
(base) PS C:\Users\chenxuqi> python Python 3.7.4 (default, Aug 9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32 Type "help", "copyright", "credits" or "license" for more information.>>> import torch>>> torch.equal(torch.tensor([1, 2]), torch.tensor([1, 2]))True>>> torch.equal(torch.tensor([1, 2]), torch.tensor([[1],[2]]))False>>> torch.equal(torch.tensor([[1, 2]]), torch.tensor([[1],[2]]))False>>>>>> torch.equal(torch.tensor([1, 2]), torch.tensor([1, 2.0]))Traceback (most recent call last): File "", line 1, in RuntimeError: Expected object of scalar type Long but got scalar type Float for argument #2 'other'>>> torch.equal(torch.tensor([1, 2]), torch.tensor([1.0, 2.0]))Traceback (most recent call last): File " ", line 1, in RuntimeError: Expected object of scalar type Long but got scalar type Float for argument #2 'other'>>> torch.equal(torch.tensor([1.0, 2.0]), torch.tensor([1.0, 2.0]))True>>>>>>
“torch.equal函數(shù)怎么使用”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關的知識可以關注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!