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)
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)
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。