您现在的位置是:首页 >学无止境 >pytorch笔记网站首页学无止境
pytorch笔记
简介pytorch笔记
创建 tensor:
- torch.tensor
- torch.ones_like
- torch.zeros_like
- torch.rand_like
- torch.rand
Returns a tensor filled with random numbers from a uniform distribution on the interval [0, 1)[0,1)
- torch.randn
Returns a tensor filled with random numbers from a normal distribution with mean 0 and variance 1 (also called the standard normal distribution).
- torch.normal(mean,std,size)
- torch.zeros
- torch.arange
torch.range() is deprecated and will be removed in a future release because its behavior is inconsistent with Python’s range builtin. Instead, use torch.arange(), which produces values in [start, end).
- torch.eye
- torch.full([n,n],x)
移动 tensor
if torch.cuda.is_available():
tensor=tensor.to('cuda')
tensor 运算
- torch.is_tensor
- torch.numel,返回元素数目
tensor 操作
- torch.cat
除了dim指定的那个维度,其他维度的shape都应该一样
- torch.reshape(a,shape)
shape可以用 [] 或 () 指定
- torch.split(a,size)
按size大小均分或者可以传入list
- torch.squeeze
- troch.tile(a,dims)
扩增a的行列
- torch.transpose(a,dim0,dim1)
- torch.unbind
- torch.unsqueeze(a,dim)
tensor 属性
风语者!平时喜欢研究各种技术,目前在从事后端开发工作,热爱生活、热爱工作。