brauerpytorch给数据增加⼀个维度使⽤ unsqueeze
>>>help(torch.squeeze)
Help on built-in function unsqueeze:
海外考试报名中心
unsqueeze(...)
unsqueeze(input, dim, out=None)-> Tensor
Returns a new tensor with a dimension of size one inrted at the
specified position.
The returned tensor shares the same underlying data with this tensor.
A :attr:`dim` value within the range ``[-input.dim()-1,input.dim()+1)``
can be ud. Negative :attr:`dim` will correspond to :meth:`unsqueeze`
timebox
攒动applied at :attr:`dim` = ``dim +input.dim()+1``.
Args:
input(Tensor): the input tensor
dim (int): the index at which to inrt the singleton dimension
out (Tensor, optional): the output tensor
Example::
>>> x = sor([1,2,3,4])
>>> torch.unsqueeze(x,0)
tensor([[1,2,3,4]])
>>> torch.unsqueeze(x,1)
vestastensor([[1],
[2],
母亲节快乐的英文
[3],
07年高考作文[4]])
也可以直接:化学符号
>>> a = torch.Tensor([1,2,3,4])
>>> a.unsqueeze(0)金融英语
tensor([[1.,2.,3.,4.]])familiar