コード例 #1
0
ファイル: networks.py プロジェクト: xiaoiker/visual-dynamics
    def __init__(self, num_scales, in_channels, out_channels, kernel_size, num_groups, num_layers, kernel_sizes):
        super(KernelDecoder, self).__init__()
        self.num_scales = num_scales
        self.in_channels = in_channels
        self.out_channels = out_channels
        self.kernel_size = kernel_size
        self.num_groups = num_groups
        self.num_layers = num_layers
        self.kernel_sizes = kernel_sizes

        # channels
        self.num_channels = self.num_scales * self.out_channels * (self.in_channels // self.num_groups)

        # modules
        self.decoder = nn.Sequential(
            ConvPool2D(
                channels = [self.num_channels] * 2,
                sampling_type = 'UP-DECONV',
                sampling_sizes = self.kernel_size
            ),
            ConvPool2D(
                channels = [self.num_channels] * self.num_layers,
                kernel_sizes = self.kernel_sizes
            ),
            nn.BatchNorm2d(self.num_channels)
        )
        self.apply(weights_init)
コード例 #2
0
    def __init__(self, scales, channels, kernel_sizes):
        super(MotionDecoder, self).__init__()
        self.scales = scales
        self.channels = channels
        self.kernel_sizes = kernel_sizes

        # modules
        self.decoder = ConvPool2D(channels=self.channels,
                                  kernel_sizes=self.kernel_sizes)
        self.apply(weights_init)
コード例 #3
0
    def __init__(self, channels, kernel_sizes, sampling_sizes):
        super(MotionEncoder, self).__init__()
        self.channels = channels
        self.kernel_sizes = kernel_sizes
        self.sampling_sizes = sampling_sizes

        # modules
        self.encoder = ConvPool2D(channels=self.channels,
                                  kernel_sizes=self.kernel_sizes,
                                  last_nonlinear=False,
                                  sampling_type='SUB-MAXPOOL',
                                  sampling_sizes=self.sampling_sizes)
        self.apply(weights_init)
コード例 #4
0
    def __init__(self, num_scales, channels, kernel_sizes, sampling_sizes):
        super(ImageEncoder, self).__init__()
        self.num_scales = num_scales
        self.channels = channels
        self.kernel_sizes = kernel_sizes
        self.sampling_sizes = sampling_sizes

        # modules
        self.encoders = []
        for k in range(num_scales):
            self.encoders.append(
                ConvPool2D(channels=self.channels,
                           kernel_sizes=self.kernel_sizes,
                           last_nonlinear=True,
                           sampling_type='SUB-MAXPOOL',
                           sampling_sizes=self.sampling_sizes))
            self.add_module('encoder-{0}'.format(k + 1), self.encoders[-1])
        self.apply(weights_init)