1 class Flatten(nn.Module):
2     def __init__(self):
3         super(Flatten,self).__init__()
4         
5     def forward(self,input):
6         shape = torch.prod(torch.tensor(x.shape[1:])).item()
7         # -1 把第一个维度保持住
8         return x.view(-1,shape)

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-04-18
  • 2022-01-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-20
  • 2022-03-03
  • 2021-09-23
  • 2021-11-26
  • 2022-01-06
  • 2022-02-16
  • 2022-12-23
相关资源
相似解决方案