Ejemplo n.º 1
0
    def __init__(self,
                 activation,
                 initType,
                 numChannels,
                 imageHeight,
                 imageWidth,
                 batchnorm=False,
                 softmax=False):
        super(SkipLSTMEnDe, self).__init__()

        self.batchnorm = batchnorm
        self.bias = not self.batchnorm
        self.initType = initType
        self.activation = None
        self.batchsize = 1
        self.numChannels = numChannels
        self.softmax = softmax

        # Encoder
        self.conv1 = nn.Conv2d(self.numChannels, 16, 3, 1, 1, bias=self.bias)
        self.conv2 = nn.Conv2d(16, 32, 3, 1, 1, bias=self.bias)
        self.conv3 = nn.Conv2d(32, 64, 3, 1, 1, bias=self.bias)

        # Decoder
        self.deconv3 = nn.ConvTranspose2d(64, 32, 3, 2, 1, 1)
        self.deconv2 = nn.ConvTranspose2d(32, 16, 3, 2, 1, 1)
        self.deconv1 = nn.ConvTranspose2d(16, 8, 3, 2, 1, 1)

        # LSTM
        self.convlstm = ConvLSTMCell(
            (int(imageWidth / 8), int(imageHeight / 8)), 64, 64, (3, 3))
        self.h, self.c = None, None

        # Skip Connections LSTM
        self.skip1 = ConvLSTMCell((int(imageWidth / 2), int(imageHeight / 2)),
                                  16, 16, (3, 3))
        self.h1, self.c1 = None, None
        self.skip2 = ConvLSTMCell((int(imageWidth / 4), int(imageHeight / 4)),
                                  32, 32, (3, 3))
        self.h2, self.c2 = None, None

        self.pool = nn.MaxPool2d(2, 2)
        self.classifier = nn.Conv2d(8, 1, 1)

        if activation == 'relu':
            self.activation = nn.ReLU(inplace=True)
        else:
            self.activation = nn.SELU(inplace=True)

        if self.batchnorm:
            self.bn1 = nn.BatchNorm2d(16)
            self.bn2 = nn.BatchNorm2d(32)
            self.bn3 = nn.BatchNorm2d(64)
            self.bn4 = nn.BatchNorm2d(32)
            self.bn5 = nn.BatchNorm2d(16)
            self.bn6 = nn.BatchNorm2d(8)
Ejemplo n.º 2
0
    def __init__(self,
                 activation,
                 initType,
                 numChannels,
                 imageHeight,
                 imageWidth,
                 softmax=False):
        super(SkipLSTMLayerNorm1D, self).__init__()

        self.initType = initType
        self.activation = None
        self.batchsize = 1
        self.numChannels = numChannels
        self.softmax = softmax

        # Encoder
        self.conv1 = nn.Conv2d(self.numChannels, 16, 3, 1, 1, bias=True)
        self.conv2 = nn.Conv2d(16, 32, 3, 1, 1, bias=True)
        self.conv3 = nn.Conv2d(32, 64, 3, 1, 1, bias=True)

        # Decoder
        self.deconv3 = nn.ConvTranspose2d(64, 32, 3, 2, 1, 1)
        self.deconv2 = nn.ConvTranspose2d(32, 16, 3, 2, 1, 1)
        self.deconv1 = nn.ConvTranspose2d(16, 8, 3, 2, 1, 1)

        # LSTM
        self.convlstm = ConvLSTMCell(
            (int(imageWidth / 8), int(imageHeight / 8)), 64, 64, (3, 3))
        self.h, self.c = None, None

        # Skip Connections LSTM
        self.skip1 = ConvLSTMCell((int(imageWidth / 2), int(imageHeight / 2)),
                                  16, 16, (3, 3))
        self.h1, self.c1 = None, None
        self.skip2 = ConvLSTMCell((int(imageWidth / 4), int(imageHeight / 4)),
                                  32, 32, (3, 3))
        self.h2, self.c2 = None, None

        self.pool = nn.MaxPool2d(2, 2)
        self.classifier = nn.Conv2d(8, 1, 1)

        if activation == 'relu':
            self.activation = nn.ReLU(inplace=True)
        else:
            self.activation = nn.SELU(inplace=True)

        self.layerNorm1 = nn.LayerNorm([256, 256])
        self.layerNorm2 = nn.LayerNorm([128, 128])
        self.layerNorm3 = nn.LayerNorm([64, 64])

        self.layerNorm4 = nn.LayerNorm([64, 64])
        self.layerNorm5 = nn.LayerNorm([128, 128])
        self.layerNorm6 = nn.LayerNorm([256, 256])
Ejemplo n.º 3
0
    def __init__(self,
                 activation,
                 initType,
                 numChannels,
                 imageHeight,
                 imageWidth,
                 softmax=False):
        super(EnDeLayerNorm_ws, self).__init__()

        self.initType = initType
        self.activation = None
        self.batchsize = 1
        self.numChannels = numChannels
        self.softmax = softmax

        # Encoder
        self.conv1 = nn.Conv2d(self.numChannels, 16, 3, 1, 1, bias=True)
        self.conv2 = nn.Conv2d(16, 32, 3, 1, 1, bias=True)
        self.conv3 = nn.Conv2d(32, 64, 3, 1, 1, bias=True)

        # Decoder
        self.deconv3 = nn.ConvTranspose2d(64, 32, 3, 2, 1, 1)
        self.deconv2 = nn.ConvTranspose2d(32, 16, 3, 2, 1, 1)
        self.deconv1 = nn.ConvTranspose2d(16, 8, 3, 2, 1, 1)

        # Conv LSTM
        self.convlstm = ConvLSTMCell(
            (int(imageWidth / 8), int(imageHeight / 8)), 64, 64, (3, 3))
        self.h, self.c = None, None

        self.pool = nn.MaxPool2d(2, 2)
        self.classifier = nn.Conv2d(8, 1, 1)

        if activation == 'relu':
            self.activation = nn.ReLU(inplace=True)
        else:
            self.activation = nn.SELU(inplace=True)

        self.layerNorm1 = LayerNormConv2d(16)
        self.layerNorm2 = LayerNormConv2d(32)
        self.layerNorm3 = LayerNormConv2d(64)

        self.layerNorm4 = LayerNormConv2d(32)
        self.layerNorm5 = LayerNormConv2d(16)
        self.layerNorm6 = LayerNormConv2d(8)