Example #1
0
    def __init__(self,
                 activation_constructor,
                 clusterInputSize,
                 Block,
                 Cstd,
                 DIM,
                 sigmoid=False):
        super(TucodecEncode1D4L, self).__init__()

        device = get_device()
        encode = True

        #downsamples and upsamples
        downsample1 = DownUp1D.downsample1(activation_constructor, Cstd, Cstd)
        upsample1 = DownUp1D.upsample1(activation_constructor, Cstd, Cstd)
        downsample2 = DownUp1D.downsample2(activation_constructor, Cstd, Cstd)
        upsample2 = DownUp1D.upsample2(activation_constructor, Cstd, Cstd)

        # 4 Linear Layers
        self.fc1 = nn.Linear(in_features=clusterInputSize, out_features=1024)
        self.fc2 = nn.Linear(in_features=1024, out_features=512)
        self.fc3 = nn.Linear(in_features=512, out_features=256)
        self.fc4 = nn.Linear(in_features=256, out_features=128)

        #main trunk first
        self.conv1 = nn.Conv1d(1, Cstd, kernel_size=3, stride=2, padding=1)
        self.gdn2 = GDN(Cstd, device, not encode)
        self.conv3 = nn.Conv1d(Cstd, Cstd, kernel_size=2, stride=2, padding=0)
        self.gdn4 = GDN(Cstd, device, not encode)
        self.rnab5 = RAB1D(encode,
                           activation_constructor,
                           Cstd,
                           sigmoid,
                           Block,
                           downsample=downsample1,
                           upsample=upsample1)
        self.conv6 = nn.Conv1d(Cstd, Cstd, kernel_size=3, stride=2)
        self.gdn7 = GDN(Cstd, device, not encode)
        self.conv8 = nn.Conv1d(Cstd, Cstd, kernel_size=3, stride=2, padding=1)
        self.rnab9 = RAB1D(encode,
                           activation_constructor,
                           Cstd,
                           sigmoid,
                           Block,
                           downsample=downsample2,
                           upsample=upsample2)

        #multi-res path
        self.convA = nn.Conv1d(Cstd, Cstd, kernel_size=3, stride=8)
        self.convB = nn.Conv1d(Cstd, Cstd, kernel_size=3, stride=4, padding=0)
        self.convC = nn.Conv1d(Cstd, Cstd, kernel_size=3, stride=2, padding=1)

        #final conv
        self.conv10 = nn.Conv1d(4 * Cstd, Cstd, kernel_size=2, stride=2)
Example #2
0
    def __init__(self,
                 activation_constructor,
                 Block,
                 Cstd,
                 DIM,
                 sigmoid=False):
        super(TucodecEncode1D0L, self).__init__()

        device = get_device()
        encode = True

        #downsamples and upsamples
        downsample1 = DownUp1D.downsample1(activation_constructor, Cstd, Cstd)
        upsample1 = DownUp1D.upsample1(activation_constructor, Cstd, Cstd)
        downsample2 = DownUp1D.downsample2(activation_constructor, Cstd, Cstd)
        upsample2 = DownUp1D.upsample2(activation_constructor, Cstd, Cstd)

        #main trunk first
        self.conv1 = nn.Conv1d(1, Cstd, kernel_size=3, stride=2, padding=1)
        self.gdn2 = GDN(Cstd, device, not encode)
        self.conv3 = nn.Conv1d(Cstd, Cstd, kernel_size=2, stride=2, padding=0)
        self.gdn4 = GDN(Cstd, device, not encode)
        self.rnab5 = RAB1D(encode,
                           activation_constructor,
                           Cstd,
                           sigmoid,
                           Block,
                           downsample=downsample1,
                           upsample=upsample1)
        self.conv6 = nn.Conv1d(Cstd, Cstd, kernel_size=3, stride=2)
        self.gdn7 = GDN(Cstd, device, not encode)
        self.conv8 = nn.Conv1d(Cstd, Cstd, kernel_size=3, stride=2, padding=1)
        self.rnab9 = RAB1D(encode,
                           activation_constructor,
                           Cstd,
                           sigmoid,
                           Block,
                           downsample=downsample2,
                           upsample=upsample2)

        #multi-res path
        self.convA = nn.Conv1d(Cstd, Cstd, kernel_size=3, stride=8)
        self.convB = nn.Conv1d(Cstd, Cstd, kernel_size=3, stride=4, padding=0)
        self.convC = nn.Conv1d(Cstd, Cstd, kernel_size=3, stride=2, padding=1)

        #final conv
        self.conv10 = nn.Conv1d(4 * Cstd, Cstd, kernel_size=2, stride=2)
Example #3
0
    def __init__(self,
                 activation_constructor,
                 Block,
                 Cstd,
                 dim,
                 sigmoid=False):
        super(TucodecDecode, self).__init__()

        device = get_device()
        encode = False

        #downsamples and upsamples
        downsample2 = DownUp.downsample2(activation_constructor, Cstd, Cstd)
        upsample2 = DownUp.upsample2(activation_constructor, Cstd, Cstd)
        downsample1 = DownUp.downsample1(activation_constructor, Cstd, Cstd)
        upsample1 = DownUp.upsample1(activation_constructor, Cstd, Cstd)

        #Keep numbering from Encoder
        self.conv10 = nn.ConvTranspose3d(Cstd,
                                         Cstd,
                                         kernel_size=(2, 2, 2),
                                         stride=2)

        self.rb10a = Block(
            encode,
            activation_constructor,
            Cstd,
        )
        self.rb10b = Block(
            encode,
            activation_constructor,
            Cstd,
        )

        self.rnab9 = RAB(encode,
                         activation_constructor,
                         Cstd,
                         sigmoid,
                         Block,
                         downsample=downsample2,
                         upsample=upsample2)
        self.conv8 = nn.ConvTranspose3d(Cstd,
                                        Cstd,
                                        kernel_size=(3, 2, 2),
                                        stride=2,
                                        padding=(1, 1, 0))

        self.gdn7 = GDN(Cstd, device, encode)
        self.conv6 = nn.ConvTranspose3d(
            Cstd,
            Cstd,
            kernel_size=(3, 4, 2),
            stride=2,
        )
        self.rnab5 = RAB(encode,
                         activation_constructor,
                         Cstd,
                         sigmoid,
                         Block,
                         downsample=downsample1,
                         upsample=upsample1)
        self.gdn4 = GDN(Cstd, device, encode)

        self.conv3 = nn.ConvTranspose3d(Cstd,
                                        Cstd,
                                        kernel_size=(2, 3, 2),
                                        stride=2,
                                        padding=(0, 1, 0))
        self.gdn2 = GDN(Cstd, device, encode)
        self.conv1 = nn.ConvTranspose3d(Cstd,
                                        1,
                                        kernel_size=(3, 3, 2),
                                        stride=2,
                                        padding=(1, 1, 0))
Example #4
0
    def __init__(self,
                 activation_constructor,
                 Block,
                 Cstd,
                 DIM,
                 sigmoid=False):
        super(TucodecDecode1D0L, self).__init__()

        device = get_device()
        encode = False

        #downsamples and upsamples
        downsample2 = DownUp1D.downsample2(activation_constructor, Cstd, Cstd)
        upsample2 = DownUp1D.upsample2(activation_constructor, Cstd, Cstd)
        downsample1 = DownUp1D.downsample1(activation_constructor, Cstd, Cstd)
        upsample1 = DownUp1D.upsample1(activation_constructor, Cstd, Cstd)

        #Keep numbering from Encoder

        self.conv10 = nn.ConvTranspose1d(Cstd, Cstd, kernel_size=2, stride=2)

        self.rb10a = Block(
            encode,
            activation_constructor,
            Cstd,
        )
        self.rb10b = Block(
            encode,
            activation_constructor,
            Cstd,
        )

        self.rnab9 = RAB1D(encode,
                           activation_constructor,
                           Cstd,
                           sigmoid,
                           Block,
                           downsample=downsample2,
                           upsample=upsample2)
        self.conv8 = nn.ConvTranspose1d(Cstd,
                                        Cstd,
                                        kernel_size=3,
                                        stride=2,
                                        padding=1,
                                        output_padding=0)

        self.gdn7 = GDN(Cstd, device, encode)
        self.conv6 = nn.ConvTranspose1d(Cstd,
                                        Cstd,
                                        kernel_size=3,
                                        stride=2,
                                        output_padding=1)
        self.rnab5 = RAB1D(encode,
                           activation_constructor,
                           Cstd,
                           sigmoid,
                           Block,
                           downsample=downsample1,
                           upsample=upsample1)
        self.gdn4 = GDN(Cstd, device, encode)

        self.conv3 = nn.ConvTranspose1d(Cstd,
                                        Cstd,
                                        kernel_size=2,
                                        stride=2,
                                        padding=0,
                                        output_padding=1)
        self.gdn2 = GDN(Cstd, device, encode)
        self.conv1 = nn.ConvTranspose1d(Cstd,
                                        1,
                                        kernel_size=3,
                                        stride=2,
                                        padding=1,
                                        output_padding=0)