def generator_three_layer_block(input_layer, out_channels, do_pixel_norm=False, conditional_layer=None, unet_end_points=None): # Upsample ret = pggan_utils.resize_twice_as_big(input_layer) # Concat extra layers. ret = pggan_utils.maybe_concat_conditional_layer(ret, conditional_layer) ret = pggan_utils.maybe_concat_unet_layer(ret, unet_end_points) # Conv conv2d_out = ret conv2d_out = pggan_utils.maybe_pixel_norm( pggan_utils.maybe_equalized_conv2d( conv2d_out, out_channels, ), do_pixel_norm=do_pixel_norm) conv2d_out = pggan_utils.maybe_pixel_norm( pggan_utils.maybe_equalized_conv2d( conv2d_out, out_channels, ), do_pixel_norm=do_pixel_norm) ret = pggan_utils.maybe_resblock(ret, out_channels, conv2d_out) return ret
def encoder_from_rgb_block(input_layer, out_channels, do_pixel_norm=False): conv2d_out = pggan_utils.maybe_pixel_norm( pggan_utils.maybe_equalized_conv2d(input_layer, out_channels, kernel_size=1), do_pixel_norm=do_pixel_norm) ret = pggan_utils.maybe_resblock(input_layer, out_channels, conv2d_out) return ret
def discriminator_from_rgb_block(input_layer, out_channels): conv2d_out = input_layer conv2d_out = pggan_utils.maybe_equalized_conv2d(conv2d_out, out_channels, kernel_size=1, is_discriminator=True) ret = pggan_utils.maybe_resblock(input_layer, out_channels, conv2d_out, is_discriminator=True) return ret
def discriminator_two_layer_block(input_layer, out_channels, maybe_gdrop_fn): input_shape = input_layer.shape input_channels = input_shape[3] conv2d_out = input_layer # The first layer's depth is the same as input. conv2d_out = pggan_utils.maybe_equalized_conv2d(maybe_gdrop_fn(conv2d_out), input_channels, is_discriminator=True) # The second layer's depth is the output channel. conv2d_out = pggan_utils.maybe_equalized_conv2d(maybe_gdrop_fn(conv2d_out), out_channels, kernel_size=3, is_discriminator=True) ret = pggan_utils.maybe_resblock(input_layer, out_channels, conv2d_out, is_discriminator=True) return ret
def encoder_two_layer_block(input_layer, out_channels, do_pixel_norm=False): input_shape = input_layer.shape input_channels = input_shape[3] conv2d_out = input_layer # The first layer's depth is the same as input. conv2d_out = pggan_utils.maybe_pixel_norm( pggan_utils.maybe_equalized_conv2d( conv2d_out, input_channels, ), do_pixel_norm=do_pixel_norm) # The second layer's depth is the output channel. conv2d_out = pggan_utils.maybe_pixel_norm( pggan_utils.maybe_equalized_conv2d(conv2d_out, out_channels, kernel_size=3), do_pixel_norm=do_pixel_norm) ret = pggan_utils.maybe_resblock(input_layer, out_channels, conv2d_out) return ret