Esempio n. 1
0
 def forward_cpu(self, x: tensor) -> tensor:
     x.reshape([x.shape[0], x.shape[1], 1, x.shape[2], x.shape[3]])
     y = super(MaxPool2d, self).forward_cpu(x)
     x.reset_shape()
     y.reshape([x.shape[0], y.shape[1], y.shape[3], y.shape[4]])
     y.init_shape = y.shape
     return y
Esempio n. 2
0
 def _backward_gpu(self, dx: tensor) -> tensor:
     dx.reshape(self.old_shape)
     return dx
Esempio n. 3
0
 def _forward_gpu(self, x: tensor) -> tensor:
     x.reshape([x.shape[0], -1])
     return x
Esempio n. 4
0
 def forward_cpu(self, x: tensor) -> tensor:
     x.reshape([x.shape[0], x.shape[1], 1, 1, x.shape[2]])
     y = super(MaxPool1d, self).forward_cpu(x)
     x.reset_shape()
     y.reshape([x.shape[0], y.shape[1], y.shape[-1]])
     return y