tensor
1、torch.(…)和torch.([…])的区别
前者参数是tensor的维度,后者参数是tensor中的数据
2、 size和shape的区别
shape is an attribute,while size is a function.
输出都是同一个tensor
3、 在函数后加_后缀表示对tensor进行就地操作(ex:X.t_()表示对X转置)
4、torch的tensor类
torch.tensor(data,dtype=None,device=None,requires_grad=None)
data - 可以是list, tuple, numpy array, scalar或其他类型,如下图分别是错误和正确的data
dtype - 可以返回想要的tensor类型
device - 可以指定返回的设备,“cuda"或"cpu”
requires_grad -可以指定是否进行记录图的操作,默认为False
5、rand()和randn()区别

rand()生成tensor内的数据是符合[0,1)范围内的均匀分布的;
randn()生成tensor内的数据是符合标准正态分布(standard normal distribution)的。
来源:CSDN
作者:二八
链接:https://blog.csdn.net/qq_34977841/article/details/103893173