def inv(self, output):
output = output.dimshuffle(0,1,2,'x').repeat(self.pool_shape[0], axis=3)
if self.depooler == 'random':
mask = self.theano_rng.uniform(size=output.shape, dtype=theano.config.floatX)
mask = T.floor(mask / mask.max(axis=3).dimshuffle(0,1,2,'x'))
output = mask * output
elif self.depooler == 'first':
mask_np = np.zeros(self.pool_shape, dtype=theano.config.floatX)
mask_np[0] = 1.0
mask = theano.shared(mask_np, borrow=True).dimshuffle('x','x','x',0)
output = mask * output
else:
output = self.depooler(output, axis=3)
return output.reshape(self.input_shape)
评论列表
文章目录