Пример #1
0
        def downsample(layer_input, filters, f_size=4):
            d = Conv2D(filters, kernel_size=f_size, strides=2,
                       padding='same')(layer_input)
            d = InstanceNormalization(axis=-1)(d)
            d = Activation('relu')(d)

            return d
Пример #2
0
 def downsample(layer_input, filters):
     y = Conv2D(filters,
                kernel_size=(3, 3),
                strides=2,
                padding='same',
                kernel_initializer=self.weight_init)(layer_input)
     y = InstanceNormalization(axis=-1)(y)
     y = Activation('relu')(y)
     return y
Пример #3
0
        def residual(layer_input, filters):
            shortcut = layer_input
            y = ReflectionPadding2D(padding=(1, 1))(layer_input)
            y = Conv2D(filters,
                       kernel_size=(3, 3),
                       strides=1,
                       padding='valid',
                       kernel_initializer=self.weight_init)(y)
            y = InstanceNormalization(axis=-1)(y)
            y = Activation('relu')(y)

            y = ReflectionPadding2D(padding=(1, 1))(y)
            y = Conv2D(filters,
                       kernel_size=(3, 3),
                       strides=1,
                       padding='valid',
                       kernel_initializer=self.weight_init)(y)
            y = InstanceNormalization(axis=-1)(y)

            return add([shortcut, y])
Пример #4
0
        def conv4(layer_input, filters, stride=2, norm=True):
            y = Conv2D(filters,
                       kernel_size=(4, 4),
                       strides=stride,
                       padding='same',
                       kernel_initializer=self.weight_init)(layer_input)

            if norm:
                y = InstanceNormalization(axis=-1)(y)

            y = LeakyReLU(0.2)(y)

            return y
Пример #5
0
 def conv7s1(layer_input, filters, final):
     y = ReflectionPadding2D(padding=(3, 3))(layer_input)
     y = Conv2D(filters,
                kernel_size=(7, 7),
                strides=1,
                padding='valid',
                kernel_initializer=self.weight_init)(y)
     if final:
         y = Activation('tanh')(y)
     else:
         y = InstanceNormalization(axis=-1)(y)
         y = Activation('relu')(y)
     return y
Пример #6
0
        def upsample(layer_input,
                     skip_input,
                     filters,
                     f_size=4,
                     dropout_rate=0):
            u = UpSampling2D(size=2)(layer_input)
            u = Conv2D(filters, kernel_size=f_size, strides=1,
                       padding='same')(u)
            u = InstanceNormalization(axis=-1)(u)
            u = Activation('relu')(u)
            if dropout_rate:
                u = Dropout(dropout_rate)(u)

            u = Concatenate()([u, skip_input])
            return u