def inflate_pool(inputs, kernel_size, padding, stride, dilation, avg_type=False, time_dim=1, time_padding=0, time_stride=None, time_dilation=1): kernel_dim = [time_dim, kernel_size, kernel_size] padding = [0, 0, time_padding, padding, padding] if time_stride is None: time_stride = time_dim stride = [time_stride, stride, stride] if avg_type == False: dilation = [time_dilation, dilation, dilation] pool3d = nn.max_pool3d(inputs, ksize=kernel_dim, strides=stride, padding=padding) else: pool3d = nn.avg_pool3d(inputs, ksize=kernel_dim, strides=stride, padding=padding) return pool3d
def build_maxpool(self, dimension, inputs): if dimension == 3: return nn.max_pool3d(input=inputs, ksize=[1, 2, 2], data_format='NCDHW', strides=None, padding="VALID") elif dimension == 2: return nn.max_pool2d(input=inputs, kszie=2, data_format="NCHW", strides=None, padding="VALID") else: return nn.max_pool1d(input=inputs, kszie=2, data_format="NCW", strides=None, padding="VALID")