ContionalGAN

C o n t i o n a l G A N ContionalGAN ContionalGAN

https://arxiv.org/abs/1411.1784


  • 生成的图像是随机的,不可预测的,无法控制网络输出特 定的图片,生成目标不明确, 可控性不强

  • 针对原始GAN不能生成具有特定属性的图片的问题, Mehdi Mirza等人提出了cGAN,其核心在于将属性信息y
    融入生成器G和判别器D中,属性y可以是任何标签信息
    , 例如图像的类别、人脸图像的面部表情等。


ContionalGAN_第1张图片


网络架构

ContionalGAN_第2张图片

ContionalGAN_第3张图片


  • cGAN生成的图像虽有很多缺陷,譬如图像边缘模糊,生成 的图像分辨率太低等,但是它为后面的Cycle-GAN开拓了道
    路,这两个模型转换图像风格时对属性特征的处理方法均受 cGAN启发。

代码

import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
import glob
gpu = tf.config.experimental.list_physical_devices(device_type='GPU')
tf.config.experimental.set_memory_growth(gpu[0], True)
print('Tensorflow version: {}'.format(tf.__version__))

在这里插入图片描述

import tensorflow.keras.datasets.mnist as mnist
(train_image, train_label), (_, _) = mnist.load_data()
train_image.shape

在这里插入图片描述

train_label.shape

在这里插入图片描述

plt.imshow(train_image[5])

ContionalGAN_第4张图片

train_label[:5]

在这里插入图片描述

train_image = train_image / 127.5  - 1
train_image = np.expand_dims(train_image, -1)

你可能感兴趣的:(ContionalGAN)