资源简介
使用Wgan生成二次元人物头像,train部分代码写的不全,自己根据需求补就行了,数据就使用李宏毅网课上提供的数据,太大了上传不了,网络使用的是DenseNet
代码片段和文件信息
from GAN.Discriminator import discriminator
from GAN.Generator import generator
from GAN.CreateData import read_data
import tensorflow as tf
import numpy as np
from PIL import Image
true_image = read_data(‘./dataset/CartoonCharacters/faces‘)
batch_size = 64
learning_rate = 1e-4
epochs = 100
train_steps = int(true_image.__len__()/batch_size) + 1
if __name__ == ‘__main__‘:
is_training = tf.placeholder(tf.bool)
dropout_rate = tf.placeholder(tf.float32)
X = tf.placeholder(tf.float32[batch_size96963])
G = generator(growth_rate_K=12is_training=is_trainingdropout_rate=dropout_rate).generator(batch_size=batch_size)
D_real = discriminator(growth_rate_K=12is_training=is_trainingdropout_rate=dropout_rate).discriminator(input=X)
D_fake = discriminator(growth_rate_K=12is_training=is_trainingdropout_rate=dropout_rate).discriminator(input=G)
G_cost = -tf.reduce_mean(D_fake)
D_cost = tf.reduce_mean(D_fake) - tf.reduce_mean(D_real)
update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS)
with tf.control_dependencies(update_ops):
G_train_op = tf.train.AdamOptimizer(learning_rate=learning_rate).minimize(G_cost)
D_train_op = tf.train.AdamOptimizer(learning_rate=learning_rate).minimize(D_cost)
sess = tf.InteractiveSession()
sess.run(tf.global_variables_initializer())
for epoch in range(epochs):
for i in range(train_steps):
start = i*batch_size
end = min((i+1)*batch_sizetrue_image.__len__())
batch = true_image[start:end]
feed_dict_real = {
is_training:True
dropout_rate:0.2
X:batch
}
feed_dict_fake = {
is_training:True
dropout_rate:0.2
}
for j in range(05):
_ D_loss = sess.run([D_train_opD_cost]feed_dict=feed_dict_real)
_ G_loss = sess.run([G_train_opG_cost]feed_dict=feed_dict_fake)
print(‘Epochs: {} training: {} D_cost: {} G_cost: {}‘.format(epoch i D_loss G_loss))
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-09-27 16:48 tensorflow-GAN-CreateCartoonFaces\
目录 0 2019-09-27 17:00 tensorflow-GAN-CreateCartoonFaces\dataset\
目录 0 2019-09-27 17:00 tensorflow-GAN-CreateCartoonFaces\dataset\CartoonCharacters\
文件 2102 2019-09-27 16:48 tensorflow-GAN-CreateCartoonFaces\train.py
目录 0 2019-09-27 16:52 tensorflow-GAN-CreateCartoonFaces\Network\
文件 0 2019-09-24 13:37 tensorflow-GAN-CreateCartoonFaces\Network\__init__.py
文件 7218 2019-09-27 13:36 tensorflow-GAN-CreateCartoonFaces\Network\DenseNet.py
目录 0 2019-09-27 16:49 tensorflow-GAN-CreateCartoonFaces\GAN\
文件 0 2019-09-27 12:34 tensorflow-GAN-CreateCartoonFaces\GAN\__init__.py
文件 290 2019-09-27 16:49 tensorflow-GAN-CreateCartoonFaces\GAN\CreateData.py
文件 319 2019-09-27 15:11 tensorflow-GAN-CreateCartoonFaces\GAN\Discriminator.py
文件 825 2019-09-27 16:49 tensorflow-GAN-CreateCartoonFaces\GAN\Generator.py
相关资源
- 已划分训练集、测试集、验证集,亚
- cudart64_101.zip
- coursera 吴恩达深度机器学习 deep lear
- 利用LSTM原理预测股市
- keras-yolov3 进行批量测试 并 保存测试
- 自动泊车效果测试-基于OPENCV与深度学
- 基于NIOSII处理器的数字钟设计
- glove6B
- wiegand维根协议驱动程序
- 基于keras实现的LSTM网络
- 深度学习-PyTorch框架实战系列.rar
- 复数网络历史介绍.docx
- 2017年最新机器学习与深度学习从基础
- 深度学习框架Tensorflow学习与应用
- 2018斯坦福深度学习Tensorflow实战课程课
- halcon_17 深度学习
- 猫狗大战dogs_vs_cats)
- Siamese-RPN_code
- 深度玻尔兹曼机
- 神经网络和深度学习—吴恩达 第三周
- ganttproject
- 深度学习 脑部图像分割
- 深度学习综述英文
- 基于tensorflow的猫狗图片的识别分类
- 吴恩达老师深度学习课程作业用到的
- word2vec 中的数学原理详解-电子版.do
- Human-level control through deep reinforcement
- pytorch:实现简单的GAN(MNIST数据集)
-
深度学习项目实战视频课程-st
yleT - FER2013数据集
评论
共有 条评论