资源简介
各种对抗神经网络(GAN)大合集
代码片段和文件信息
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
import numpy as np
import matplotlib as mpl
mpl.use(‘Agg‘)
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import os sys
sys.path.append(‘utils‘)
from nets import *
from datas import *
def sample_z(m n):
return np.random.uniform(-1. 1. size=[m n])
# for test
def sample_y(m n ind):
y = np.zeros([mn])
for i in range(m):
y[i i%8] = 1
#y[:7] = 1
#y[-10] = 1
return y
def concat(zy):
return tf.concat([zy]1)
class CGAN_Classifier(object):
def __init__(self generator discriminator classifier data):
self.generator = generator
self.discriminator = discriminator
self.classifier = classifier
self.data = data
# data
self.z_dim = self.data.z_dim
self.y_dim = self.data.y_dim # condition
self.size = self.data.size
self.channel = self.data.channel
self.X = tf.placeholder(tf.float32 shape=[None self.size self.size self.channel])
self.z = tf.placeholder(tf.float32 shape=[None self.z_dim])
self.y = tf.placeholder(tf.float32 shape=[None self.y_dim])
# nets
self.G_sample = self.generator(concat(self.z self.y))
self.D_real _ = self.discriminator(self.X)
self.D_fake _ = self.discriminator(self.G_sample reuse = True)
self.C_real = self.classifier(self.X)
self.C_fake = self.classifier(self.G_sample reuse = True)
# loss
self.D_loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(logits=self.D_real labels=tf.ones_like(self.D_real))) + tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(logits=self.D_fake labels=tf.zeros_like(self.D_fake)))
self.G_loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(logits=self.D_fake labels=tf.ones_like(self.D_fake)))
self.C_real_loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=self.C_real labels=self.y)) # real label
self.C_fake_loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=self.C_fake labels=self.y))
# solver
self.D_solver = tf.train.AdamOptimizer(learning_rate=2e-4 beta1=0.5).minimize(self.D_loss var_list=self.discriminator.vars)
self.G_solver = tf.train.AdamOptimizer(learning_rate=2e-4 beta1=0.5).minimize(self.G_loss + self.C_fake_loss var_list=self.generator.vars)
self.C_real_solver = tf.train.AdamOptimizer(learning_rate=2e-4 beta1=0.5).minimize(self.C_real_loss var_list=self.classifier.vars)
#self.C_fake_solver = tf.train.AdamOptimizer(learning_rate=2e-4 beta1=0.5).minimize(self.C_fake_loss var_list=self.generator.vars)
self.saver = tf.train.Saver()
gpu_options = tf.GPUOptions(allow_growth=True)
self.sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))
def train(self sample_dir ckpt_dir=‘ckpt‘ training_epoches = 1000000 batch_size = 32):
fig_count = 0
self.sess.run(tf.global_variables_initializer())
for epoch in range(training_epoches):
# update D
for _ in range(1):
X_b y_b = self.data(batch_size)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-09-08 03:23 GAN-master\
目录 0 2017-09-08 03:23 GAN-master\Datas\
目录 0 2017-09-08 03:23 GAN-master\Datas\mnist\
文件 1648877 2017-09-08 03:23 GAN-master\Datas\mnist\t10k-images-idx3-ubyte.gz
文件 4542 2017-09-08 03:23 GAN-master\Datas\mnist\t10k-labels-idx1-ubyte.gz
文件 9912422 2017-09-08 03:23 GAN-master\Datas\mnist\train-images-idx3-ubyte.gz
文件 28881 2017-09-08 03:23 GAN-master\Datas\mnist\train-labels-idx1-ubyte.gz
文件 12072 2017-09-08 03:23 GAN-master\README.md
目录 0 2017-09-08 03:23 GAN-master\README\
目录 0 2017-09-08 03:23 GAN-master\README\images\
文件 7178 2017-09-08 03:23 GAN-master\README\images\cgan.png
文件 6753 2017-09-08 03:23 GAN-master\README\images\gan.png
文件 4228 2017-09-08 03:23 GAN-master\README\images\infogan1.png
文件 4777 2017-09-08 03:23 GAN-master\README\images\infogan2.png
目录 0 2017-09-08 03:23 GAN-master\README\results\
文件 47347 2017-09-08 03:23 GAN-master\README\results\cgan_mlp.png
文件 151303 2017-09-08 03:23 GAN-master\README\results\face3D_dcgan.png
目录 0 2017-09-08 03:23 GAN-master\Samples\
目录 0 2017-09-08 03:23 GAN-master\Samples\mnist_cgan_classifier\
文件 32085 2017-09-08 03:23 GAN-master\Samples\mnist_cgan_classifier\000_0.png
文件 14637 2017-09-08 03:23 GAN-master\Samples\mnist_cgan_classifier\001_1.png
文件 13206 2017-09-08 03:23 GAN-master\Samples\mnist_cgan_classifier\002_2.png
文件 12778 2017-09-08 03:23 GAN-master\Samples\mnist_cgan_classifier\003_3.png
文件 12493 2017-09-08 03:23 GAN-master\Samples\mnist_cgan_classifier\004_4.png
文件 12609 2017-09-08 03:23 GAN-master\Samples\mnist_cgan_classifier\005_5.png
文件 12861 2017-09-08 03:23 GAN-master\Samples\mnist_cgan_classifier\006_6.png
文件 11793 2017-09-08 03:23 GAN-master\Samples\mnist_cgan_classifier\348_8.png
目录 0 2017-09-08 03:23 GAN-master\Samples\mnist_cgan_conv\
文件 31917 2017-09-08 03:23 GAN-master\Samples\mnist_cgan_conv\000_0.png
文件 13567 2017-09-08 03:23 GAN-master\Samples\mnist_cgan_conv\001_1.png
文件 11557 2017-09-08 03:23 GAN-master\Samples\mnist_cgan_conv\002_2.png
............此处省略127个文件信息
相关资源
- Python-用python3opencv3做的中国车牌识别
- Python-Intel开源增强学习框架Coach
- Python-CENet用于2D医学图像分割的上下文
- Python-基于深度神经网络和蒙特卡罗树
- Python-SPNLearningAffinityviaSpatialPropagatio
- Python-效果超赞的图片自动增强GANs非成
- Python-VoiceactivitydetectionVAD语音端点检测
- Python-TensorFlow实现的人脸性别年龄识别
- Python-waifu2x利用卷积神经网络放大图片
- Python-TheElementsofStatisticalLearningESL的中
- Python-基于Tensorflow和Keras实现端到端的
- Python-MuseGAN用于乐曲生成的AI
- Python-简单快速实时可定制的机器学习
- Python-PySceneDetect基于PythonOpenCV实现的视
- Python-输入输出隐马尔可夫模型IOHMM的
- Python-基于OpenCVKerasTensorFlow实现深度换
- Python-在PyTorch中关注神经机器翻译的最
- Python-PointSIFT一种类似SIFT的网络模块用
- Python-O2O优惠券使用预测的第一名解决
- Python-TensorFlow神经机翻译seq2seq教程
- Python-FastDTW的一个Python实现
- Python-人体姿势估计和跟踪的简单基线
- Python-Pytorch实现的CRAFT文本检测器
- Python-2016CCF大数据精准营销中搜狗用户
- Python-YOLOv3的PyTorch完整实现
- Python-人群计数相关资源列表
- Python-那些值得读的深度学习论文集合
- Python-利用深度学习预测比特币价格
- Python-基于卷积神经网络的Keras音频分
- Python-PySpark编程最佳实践指南
评论
共有 条评论