分类:PyTorch
2020
10-08
2020
10-08
问题:如何经过convTransposed1d输出指定大小的特征?importtorchfromtorchimportnnimporttorch.nn.functionalasFconv1=nn.Conv1d(1,2,3,padding=1)conv2=nn.Conv1d(in_channels=2,out_channels=4,kernel_size=3,padding=1)#转置卷积dconv1=nn.ConvTranspose1d(4,1,kernel_size=3,stride=2,padding=1,output_padding=1)x=torch.randn(16,1,8)print(x.size())x1=conv1(x)x2=conv2(x1)print(x2.size...
继续阅读 >
2020
10-08
2020
10-08
二维的情况先用二维tensor作为例子,方便理解。permute作用为调换Tensor的维度,参数为调换的维度。例如对于一个二维Tensor来说,调用tensor.permute(1,0)意为将1轴(列轴)与0轴(行轴)调换,相当于进行转置。In[20]:aOut[20]:tensor([[0,1,2],[3,4,5]])In[21]:a.permute(1,0)Out[21]:tensor([[0,3],[1,4],[2,5]])如果使用view(3,2)或reshape(3,2),得到的tensor并不是转置的效...
继续阅读 >
2020
10-08