pytorch-Flatten operation

. 1  class The Flatten (nn.Module):
 2      DEF  the __init__ (Self):
 . 3          Super (The Flatten, Self). The __init__ ()
 . 4          
. 5      DEF Forward (Self, INPUT):
 . 6          Shape = torch.prod (torch.tensor (X. Shape [. 1 :].)) Item ()
 . 7          # -1 to hold the first dimension 
. 8          return x.view (-1, Shape)

 

Guess you like

Origin www.cnblogs.com/fxw-learning/p/12331538.html