一些基础的操作: import torch as th a=th.rand(3,4) #随机数,维度为3,4的tensor b=th.rand(4)print(a)print(b) a+b tensor([[0.3777, 0.4128, 0.6244, 0.7772], [0.0859, 0.9350, 0.1705, 0.9116], [0.4136, 0.1211, 0.5960, 0.8962]]) tensor([0.5063, 0.4809, 0.4810, 0.4716]) ten…