生成对抗网络原理及代码解析,还介绍了神经网络的基础知识,对于GAN是什么,能做什么进行深入解析和科普。

注脚

展开查看详情

1.LOGO 生成对抗网络代码解析及原理 互联网新技术在线教育领航者

2.GAN LOGO • GAN简介 • GAN预备知识 • GAN网络实战分析 • 生成手写数字 demo分析 • 常见其他网络和改进策略 互联网新技术在线教育领航者

3.GAN 背景 LOGO Ian Goodfellow Generative Adversarial Networks(arxiv:https://arxiv.org/abs/1406.2661) Yann LeCun称为"过去十年机器学习界最有趣的idea" Generative:生成式模型 Adversarial: 采取对抗的策略 Networks: 网络(不一定是深度学习) 互联网新技术在线教育领航者

4.GAN 背景 LOGO • 3D-ED-GAN - Shape Inpainting using 3D Generative Adversarial Network and Recurrent Convolutional Networks iGAN - Generative Visual Manipulation on the Natural Image Manifold (github) • 3D-GAN - Learning a Probabilistic Latent Space of Object Shapes via 3D Generative-Adversarial Modeling(github) • Improved GAN - Improved Techniques for Training GANs (github) • 3D-IWGAN - Improved Adversarial Systems for 3D Object Generation and Reconstruction (github) • In2I - In2I : Unsupervised Multi-Image-to-Image Translation Using Generative Adversarial Networks • 3D-RecGAN - 3D Object Reconstruction from a Single Depth View with Adversarial Learning (github) • InfoGAN - InfoGAN: Interpretable Representation Learning by Information Maximizing Generative Adversarial Nets (github) • ABC-GAN - ABC-GAN: Adaptive Blur and Control for improved training stability of Generative Adversarial Networks (github) • IRGAN - IRGAN: A Minimax Game for Unifying Generative and Discriminative Information Retrieval models • ABC-GAN - GANs for LIFE: Generative Adversarial Networks for Likelihood Free Inference • Iterative-GAN - Two Birds with One Stone: Iteratively Learn Facial Attributes with GANs (github) • AC-GAN - Conditional Image Synthesis With Auxiliary Classifier GANs • IVE-GAN - IVE-GAN: Invariant Encoding Generative Adversarial Networks • acGAN - Face Aging With Conditional Generative Adversarial Networks • iVGAN - Towards an Understanding of Our World by GANing Videos in the Wild (github) • ACtuAL - ACtuAL: Actor-Critic Under Adversarial Learning • IWGAN - On Unifying Deep Generative Models • AdaGAN - AdaGAN: Boosting Generative Models • KBGAN - KBGAN: Adversarial Learning for Knowledge Graph Embeddings • AE-GAN - AE-GAN: adversarial eliminating with GAN • KGAN - KGAN: How to Break The Minimax Game in GAN • AEGAN - Learning Inverse Mapping by Autoencoder based Generative Adversarial Nets • l-GAN - Representation Learning and Adversarial Generation of 3D Point Clouds https://github.com/hindupuravinash/the-gan-zoo • AffGAN - Amortised MAP Inference for Image Super-resolution • LAGAN - Learning Particle Physics by Example: Location-Aware Generative Adversarial Networks for Physics Synthesis • AL-CGAN - Learning to Generate Images of Outdoor Scenes from Attributes and Semantic Layouts • LAPGAN - Deep Generative Image Models using a Laplacian Pyramid of Adversarial Networks (github) • ALI - Adversarially Learned Inference • LD-GAN - Linear Discriminant Generative Adversarial Networks • AlignGAN - AlignGAN: Learning to Align Cross-Domain Images with Conditional Generative Adversarial Networks • LDAN - Label Denoising Adversarial Network (LDAN) for Inverse Lighting of Face Images • AM-GAN - Activation Maximization Generative Adversarial Nets • LeakGAN - Long Text Generation via Adversarial Training with Leaked Information • AnoGAN - Unsupervised Anomaly Detection with Generative Adversarial Networks to Guide Marker Discovery • LeGAN - Likelihood Estimation for Generative Adversarial Networks • ARAE - Adversarially Regularized Autoencoders for Generating Discrete Structures (github) • LGAN - Global versus Localized Generative Adversarial Nets • ARDA - Adversarial Representation Learning for Domain Adaptation • LR-GAN - LR-GAN: Layered Recursive Generative Adversarial Networks for Image Generation • ARIGAN - ARIGAN: Synthetic Arabidopsis Plants using Generative Adversarial Network • LS-GAN - Loss-Sensitive Generative Adversarial Networks on Lipschitz Densities • ArtGAN - ArtGAN: Artwork Synthesis with Conditional Categorial GANs • LSGAN - Least Squares Generative Adversarial Networks • AttGAN - Arbitrary Facial Attribute Editing: Only Change What You Want • MAD-GAN - Multi-Agent Diverse Generative Adversarial Networks • AttnGAN - AttnGAN: Fine-Grained Text to Image Generation with Attentional Generative Adversarial Networks • MAGAN - MAGAN: Margin Adaptation for Generative Adversarial Networks • b-GAN - Generative Adversarial Nets from a Density Ratio Estimation Perspective • MalGAN - Generating Adversarial Malware Examples for Black-Box Attacks Based on GAN • Bayesian GAN - Deep and Hierarchical Implicit Models (github) • MaliGAN - Maximum-Likelihood Augmented Discrete Generative Adversarial Networks • Bayesian GAN - Bayesian GAN • MARTA-GAN - Deep Unsupervised Representation Learning for Remote Sensing Images • BCGAN - Bayesian Conditional Generative Adverserial Networks • McGAN - McGan: Mean and Covariance Feature Matching GAN • BCGAN - Bidirectional Conditional Generative Adversarial networks • MD-GAN - Learning to Generate Time-Lapse Videos Using Multi-Stage Dynamic Generative Adversarial Networks • BEGAN - BEGAN: Boundary Equilibrium Generative Adversarial Networks • MDGAN - Mode Regularized Generative Adversarial Networks • BGAN - Binary Generative Adversarial Networks for Image Retrieval (github) • MedGAN - Generating Multi-label Discrete Electronic Health Records using Generative Adversarial Networks • BiGAN - Adversarial Feature Learning • MGAN - Precomputed Real-Time Texture Synthesis with Markovian Generative Adversarial Networks (github) • BS-GAN - Boundary-Seeking Generative Adversarial Networks • MGGAN - Multi-Generator Generative Adversarial Nets • C-RNN-GAN - C-RNN-GAN: Continuous recurrent neural networks with adversarial training (github) • MIX+GAN - Generalization and Equilibrium in Generative Adversarial Nets (GANs) • CaloGAN - CaloGAN: Simulating 3D High Energy Particle Showers in Multi-Layer Electromagnetic Calorimeters with Generative Adversarial Networks (github) • MLGAN - Metric Learning-based Generative Adversarial Network • CAN - CAN: Creative Adversarial Networks, Generating Art by Learning About Styles and Deviating from Style Norms • MMD-GAN - MMD GAN: Towards Deeper Understanding of Moment Matching Network (github) • CatGAN - Unsupervised and Semi-supervised Learning with Categorical Generative Adversarial Networks • MMGAN - MMGAN: Manifold Matching Generative Adversarial Network for Generating Images • CatGAN - CatGAN: Coupled Adversarial Transfer for Domain Generation • MoCoGAN - MoCoGAN: Decomposing Motion and Content for Video Generation (github) • CausalGAN - CausalGAN: Learning Causal Implicit Generative Models with Adversarial Training • MPM-GAN - Message Passing Multi-Agent GANs • CC-GAN - Semi-Supervised Learning with Context-Conditional Generative Adversarial Networks (github) • MuseGAN - MuseGAN: Symbolic-domain Music Generation and Accompaniment with Multi-track Sequential Generative Adversarial Networks • CDcGAN - Simultaneously Color-Depth Super-Resolution with Conditional Generative Adversarial Network • MV-BiGAN - Multi-view Generative Adversarial Networks • CGAN - Conditional Generative Adversarial Nets • OptionGAN - OptionGAN: Learning Joint Reward-Policy Options using Generative Adversarial Inverse Reinforcement Learning • CGAN - Controllable Generative Adversarial Network • ORGAN - Objective-Reinforced Generative Adversarial Networks (ORGAN) for Sequence Generation Models • Chekhov GAN - An Online Learning Approach to Generative Adversarial Networks • ORGAN - 3D Reconstruction of Incomplete Archaeological Objects Using a Generative Adversary Network • CM-GAN - CM-GANs: Cross-modal Generative Adversarial Networks for Common Representation Learning • PAN - Perceptual Adversarial Networks for Image-to-Image Transformation • CoAtt-GAN - Are You Talking to Me? Reasoned Visual Dialog Generation through Adversarial Learning • PassGAN - PassGAN: A Deep Learning Approach for Password Guessing • CoGAN - Coupled Generative Adversarial Networks • Perceptual GAN - Perceptual Generative Adversarial Networks for Small Object Detection • ConceptGAN - Learning Compositional Visual Concepts with Mutual Consistency • PGAN - Probabilistic Generative Adversarial Networks • Conditional cycleGAN - Conditional CycleGAN for Attribute Guided Face Image Generation • Pip-GAN - Pipeline Generative Adversarial Networks for Facial Images Generation with Multiple Attributes • constrast-GAN - Generative Semantic Manipulation with Contrasting GAN • pix2pix - Image-to-Image Translation with Conditional Adversarial Networks (github) • Context-RNN-GAN - Contextual RNN-GANs for Abstract Reasoning Diagram Generation • PixelGAN - PixelGAN Autoencoders • Coulomb GAN - Coulomb GANs: Provably Optimal Nash Equilibria via Potential Fields • Pose-GAN - The Pose Knows: Video Forecasting by Generating Pose Futures • Cover-GAN - Generative Steganography with Kerckhoffs' Principle based on Generative Adversarial Networks • PPGN - Plug & Play Generative Networks: Conditional Iterative Generation of Images in Latent Space • Cramèr GAN - The Cramer Distance as a Solution to Biased Wasserstein Gradients • PrGAN - 3D Shape Induction from 2D Views of Multiple Objects • crVAE-GAN - Channel-Recurrent Variational Autoencoders • PSGAN - Learning Texture Manifolds with the Periodic Spatial GAN • CS-GAN - Improving Neural Machine Translation with Conditional Sequence Generative Adversarial Nets • PS²-GAN - High-Quality Facial Photo-Sketch Synthesis Using Multi-Adversarial Networks • CVAE-GAN - CVAE-GAN: Fine-Grained Image Generation through Asymmetric Training • RankGAN - Adversarial Ranking for Language Generation • CycleGAN - Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks (github) • RCGAN - Real-valued (Medical) Time Series Generation with Recurrent Conditional GANs • D2GAN - Dual Discriminator Generative Adversarial Nets • RefineGAN - Compressed Sensing MRI Reconstruction with Cyclic Loss in Generative Adversarial Networks • DAGAN - Data Augmentation Generative Adversarial Networks • RenderGAN - RenderGAN: Generating Realistic Labeled Data • DAN - Distributional Adversarial Networks • ResGAN - Generative Adversarial Network based on Resnet for Conditional Image Restoration • DCGAN - Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks(github) • RNN-WGAN - Language Generation with Recurrent Generative Adversarial Networks without Pre-training(github) • DeblurGAN - DeblurGAN: Blind Motion Deblurring Using Conditional Adversarial Networks (github) • RPGAN - Stabilizing GAN Training with Multiple Random Projections (github) • DeliGAN - DeLiGAN : Generative Adversarial Networks for Diverse and Limited Data (github) • RTT-GAN - Recurrent Topic-Transition GAN for Visual Paragraph Generation • DiscoGAN - Learning to Discover Cross-Domain Relations with Generative Adversarial Networks • RWGAN - Relaxed Wasserstein with Applications to GANs • DistanceGAN - One-Sided Unsupervised Domain Mapping • SAD-GAN - SAD-GAN: Synthetic Autonomous Driving using Generative Adversarial Networks • DM-GAN - Dual Motion GAN for Future-Flow Embedded Video Prediction • SalGAN - SalGAN: Visual Saliency Prediction with Generative Adversarial Networks (github) • DNA-GAN - DNA-GAN: Learning Disentangled Representations from Multi-Attribute Images • SBADA-GAN - From source to target and back: symmetric bi-directional adaptive GAN • DR-GAN - Representation Learning by Rotating Your Faces • SD-GAN - Semantically Decomposing the Latent Spaces of Generative Adversarial Networks • DRAGAN - How to Train Your DRAGAN (github) • SEGAN - SEGAN: Speech Enhancement Generative Adversarial Network • DRPAN - Discriminative Region Proposal Adversarial Networks for High-Quality Image-to-Image Translation • SeGAN - SeGAN: Segmenting and Generating the Invisible • DSP-GAN - Depth Structure Preserving Scene Image Generation • SegAN - SegAN: Adversarial Network with Multi-scale L1 Loss for Medical Image Segmentation • DTN - Unsupervised Cross-Domain Image Generation • SeqGAN - SeqGAN: Sequence Generative Adversarial Nets with Policy Gradient (github) • DualGAN - DualGAN: Unsupervised Dual Learning for Image-to-Image Translation • SGAN - Texture Synthesis with Spatial Generative Adversarial Networks • Dualing GAN - Dualing GANs • SGAN - Stacked Generative Adversarial Networks (github) • EBGAN - Energy-based Generative Adversarial Network • SGAN - Steganographic Generative Adversarial Networks • ED//GAN - Stabilizing Training of Generative Adversarial Networks through Regularization • SimGAN - Learning from Simulated and Unsupervised Images through Adversarial Training • EGAN - Enhanced Experience Replay Generation for Efficient Reinforcement Learning • SketchGAN - Adversarial Training For Sketch Retrieval • ExprGAN - ExprGAN: Facial Expression Editing with Controllable Expression Intensity • SL-GAN - Semi-Latent GAN: Learning to generate and modify facial images from attributes • f-GAN - f-GAN: Training Generative Neural Samplers using Variational Divergence Minimization • SN-GAN - Spectral Normalization for Generative Adversarial Networks (github) • FF-GAN - Towards Large-Pose Face Frontalization in the Wild • Sobolev GAN - Sobolev GAN • FIGAN - Frame Interpolation with Multi-Scale Deep Loss Functions and Generative Adversarial Networks • Softmax-GAN - Softmax GAN • Fila-GAN - Synthesizing Filamentary Structured Images with GANs • Splitting GAN - Class-Splitting Generative Adversarial Networks • Fisher GAN - Fisher GAN • SRGAN - Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network 互联网新技术在线教育领航者 • • Flow-GAN - Flow-GAN: Bridging implicit and prescribed learning in generative models FSEGAN - Exploring Speech Enhancement with Generative Adversarial Networks for Robust Speech Recognition • • SS-GAN - Semi-supervised Conditional GANs ss-InfoGAN - Guiding InfoGAN with Semi-Supervision • FTGAN - Hierarchical Video Generation from Orthogonal Information: Optical Flow and Texture • SSGAN - SSGAN: Secure Steganography Based on Generative Adversarial Networks • GAMN - Generative Adversarial Mapping Networks • SSL-GAN - Semi-Supervised Learning with Context-Conditional Generative Adversarial Networks • GAN - Generative Adversarial Networks (github) • ST-GAN - Style Transfer Generative Adversarial Networks: Learning to Play Chess Differently • GAN-ATV - A Novel Approach to Artistic Textual Visualization via GAN • StackGAN - StackGAN: Text to Photo-realistic Image Synthesis with Stacked Generative Adversarial Networks • GAN-CLS - Generative Adversarial Text to Image Synthesis (github) • StarGAN - StarGAN: Unified Generative Adversarial Networks for Multi-Domain Image-to-Image Translation(github)

5.GAN能做什么? LOGO https://arxiv.org/pdf/1701.00160.pdf Lotter, W., Kreiman, G., and Cox, D. (2015). Unsupervised learning of visual structure using predictive generative networks. arXiv preprint arXiv:1511.06380 . 互联网新技术在线教育领航者

6.GAN能做什么? LOGO https://arxiv.org/pdf/1701.00160.pdf Ledig, C., Theis, L., Huszar, F., Caballero, J., Aitken, A. P., Tejani, A., Totz, J., Wang, Z., and Shi, W. (2016). Photo-realistic single image super-resolution using a generative adversarial network. CoRR, abs/1609.04802. 互联网新技术在线教育领航者

7.超分辨率科普 LOGO SRCNN Chao Dong, Chen Change Loy, Kaiming He, Xiaoou Tang. Learning a Deep Convolutional Network for Image Super-Resolution, in Proceedings of European Conference on Computer Vision (ECCV), 2014 互联网新技术在线教育领航者

8.GAN能做什么? LOGO https://arxiv.org/pdf/1701.00160.pdf https://www.youtube.com/watch?v=9c4z6YsBGQ0 互联网新技术在线教育领航者

9.GAN能做什么? LOGO https://arxiv.org/pdf/1701.00160.pdf Isola, P., Zhu, J.-Y., Zhou, T., and Efros, A. A. (2016). Image-to-image transla- tion with conditional adversarial networks. arXiv preprint arXiv:1611.07004 . 互联网新技术在线教育领航者

10.GAN能做什么? LOGO Videos http://web.mit.edu/vondrick/tinyvideo/ http://carlvondrick.com/tinyvideo/ 互联网新技术在线教育领航者

11.GAN能做什么? LOGO 互联网新技术在线教育领航者

12.GAN能做什么? starGAN LOGO http://cn.arxiv.org/pdf/1711.09020.pdf 互联网新技术在线教育领航者

13.GAN LOGO • GAN简介 • GAN预备知识 • GAN网络实战分析 • 生成手写数字 demo分析 • 常见其他网络和改进策略 互联网新技术在线教育领航者

14.神经网络科普 LOGO 互联网新技术在线教育领航者

15.神经网络科普 网络设计 LOGO 神经网络常见层(食材种类) 网络配置 网络训练流程(炒菜流程) • 全连接层 • 损失函数 • 预训练模型(高汤) • 激活层 • 优化器 • 训练流程 • BN层 • 激活函数 • 数据预处理 • Dropout层 • 性能评估 • 数据增强 • 卷积层 • 初始化方法 • … • 池化层 • 正则项 • 循环层RNN • … • Embedding层 • Merge层 • … 互联网新技术在线教育领航者

16.神经网络科普 全连接层 LOGO http://www.jianshu.com/p/88bb976ccbd9 互联网新技术在线教育领航者

17.神经网络科普 激活层 LOGO Sigmoid tanh ReLU Leaky ReLU 互联网新技术在线教育领航者 http://www.cnblogs.com/rgvb178/p/6055213.html

18.神经网络科普 反向传播 LOGO https://zhuanlan.zhihu.com/p/23270674 互联网新技术在线教育领航者

19.神经网络科普 优化器选择 LOGO https://www.jiqizhixin.com/articles/7c1ed66d-6742-43cc-9f47-89cd8cb5d9c0 互联网新技术在线教育领航者

20.神经网络科普 卷积层 LOGO 互联网新技术在线教育领航者

21.神经网络科普 卷积层 LOGO 互联网新技术在线教育领航者

22.神经网络科普 卷积层 LOGO 互联网新技术在线教育领航者

23.神经网络科普 卷积层 LOGO 互联网新技术在线教育领航者

24.神经网络科普 池化层 LOGO pooling 层的运算方法基本是和卷积层是一样的。 输入:n*c*w0*h0 输出:n*c*w1*h1 和卷积层的区别就是其中的 c 保持不变 w1=(w0+2*pad-kernel_size)/stride+1; h1=(h0+2*pad-kernel_size)/stride+1; 互联网新技术在线教育领航者

25.神经网络科普 常用解决套路 LOGO 互联网新技术在线教育领航者

26.神经网络科普 图像问题基本套路 LOGO 互联网新技术在线教育领航者

27.GAN LOGO • GAN简介 • GAN预备知识 • GAN网络实战分析 • 生成手写数字 demo分析 • 常见其他网络和改进策略 互联网新技术在线教育领航者

28.GAN 玩法 LOGO Generative Adversarial Nets 互联网新技术在线教育领航者

29.GAN 换种思路分析 LOGO GAN的思路:一个生成器,一个判别器 生成器G 判别器D GoodFellow的论文证明了GAN 全局最小点的充分必要条件是: 互联网新技术在线教育领航者 可以以假乱真了

30.GAN 分析问题 LOGO • 目标函数如何设定? • 如何生成图片? • G 和 D应该如何设置? • 如何进行训练? 互联网新技术在线教育领航者

31.GAN 目标函数确定 LOGO • 整个式子由两项构成。x表示真实图片,z表示输入G网络的噪声,而G(z)表示G网络生成的图片。 • D(x)表示D网络判断真实图片是否真实的概率(因为x就是真实的,所以对于D来说,这个值越接近1越好 )。而D(G(z))是D网络判断G生成的图片的是否真实的概率。 • G的目的:G应该希望自己生成的图片“越接近真实越好”。 • D的目的:D的能力越强,D(x)应该越大,D(G(x))应该越小。这时V(D,G)会变大。因此式子对于D来说是 求最大(max_D) • trick:为了前期加快训练,生成器的训练可以把 log(1-D(G(z))) 换成 -log(D(G(z))) 互联网新技术在线教育领航者

32.GAN 图片生成 训练方案 LOGO Generative Adversarial Nets 互联网新技术在线教育领航者

33.GAN 图片生成 训练方案 LOGO input1 1 0 train output 1 T output T input1 train input2 for 迭代 in range(迭代总数): for batch in range(batch_size): 新batch = input1的batch + input2的batch (batch加倍了哦) for 轮数 in range(判别器总轮数): 步骤一 步骤二 互联网新技术在线教育领航者

34.通用case 手写数字图像生成 LOGO 互联网新技术在线教育领航者

35.GAN 图片生成 生成器G LOGO noise = np.random.uniform(-1, 1, (batch_size, latent_size)) def generator_model(): model = Sequential() model.add(Dense(input_dim=100, output_dim=1024)) model.add(Activation('relu')) model.add(Dense(128*7*7)) model.add(BatchNormalization()) model.add(Activation('relu')) model.add(Reshape((7, 7, 128), input_shape=(128*7*7,))) model.add(UpSampling2D(size=(2, 2))) model.add(Conv2D(64, (5, 5), padding='same')) model.add(Activation('relu')) model.add(UpSampling2D(size=(2, 2))) model.add(Conv2D(1, (5, 5), padding='same')) model.add(Activation('tanh')) return model https://github.com/jacobgil/keras-dcgan/blob/master/dcgan.py 互联网新技术在线教育领航者

36.GAN 图片生成 判别器D LOGO def discriminator_model(): model = Sequential() model.add(Conv2D(64, (5, 5), padding='same',input_shape=(28, 28, 1))) model.add(Activation('tanh')) model.add(MaxPooling2D(pool_size=(2, 2))) model.add(Conv2D(128, (5, 5))) model.add(Activation('tanh')) model.add(MaxPooling2D(pool_size=(2, 2))) model.add(Flatten()) model.add(Dense(1024)) model.add(Activation('tanh')) model.add(Dense(1)) model.add(Activation('sigmoid')) return model 互联网新技术在线教育领航者

37. GAN 图片生成 辅助函数 LOGO def generator_containing_discriminator(g, d): def combine_images(generated_images): model = Sequential() num = generated_images.shape[0] model.add(g) width = int(math.sqrt(num)) d.trainable = False height = int(math.ceil(float(num)/width)) model.add(d) shape = generated_images.shape[1:3] return model image = np.zeros((height*shape[0], width*shape[1]), dtype=generated_images.dtype) for index, img in enumerate(generated_images): i = int(index/width) j = index % width image[i*shape[0]:(i+1)*shape[0], j*shape[1]:(j+1)*shape[1]] = \ img[:, :, 0] return image 互联网新技术在线教育领航者

38.GAN 图片生成 训练 LOGO for epoch in range(100): def train(BATCH_SIZE): print("Epoch is", epoch) (X_train, y_train), (X_test, y_test) = mnist.load_data() print("Number of batches", int(X_train.shape[0]/BATCH_SIZE)) X_train = (X_train.astype(np.float32) - 127.5)/127.5 for index in range(int(X_train.shape[0]/BATCH_SIZE)): X_train = X_train[:, :, :, None] noise = np.random.uniform(-1, 1, size=(BATCH_SIZE, 100)) X_test = X_test[:, :, :, None] image_batch = X_train[index*BATCH_SIZE:(index+1)*BATCH_SIZE] # X_train = X_train.reshape((X_train.shape, 1) + X_train.shape[1:]) generated_images = g.predict(noise, verbose=0) d = discriminator_model() if index % 20 == 0: g = generator_model() image = combine_images(generated_images) d_on_g = generator_containing_discriminator(g, d) image = image*127.5+127.5 d_optim = SGD(lr=0.0005, momentum=0.9, nesterov=True) Image.fromarray(image.astype(np.uint8)).save( g_optim = SGD(lr=0.0005, momentum=0.9, nesterov=True) str(epoch)+"_"+str(index)+".png") g.compile(loss='binary_crossentropy', optimizer="SGD") X = np.concatenate((image_batch, generated_images)) d_on_g.compile(loss='binary_crossentropy', optimizer=g_optim) y = [1] * BATCH_SIZE + [0] * BATCH_SIZE d.trainable = True d_loss = d.train_on_batch(X, y) d.compile(loss='binary_crossentropy', optimizer=d_optim) print("batch %d d_loss : %f" % (index, d_loss)) noise = np.random.uniform(-1, 1, (BATCH_SIZE, 100)) d.trainable = False g_loss = d_on_g.train_on_batch(noise, [1] * BATCH_SIZE) d.trainable = True print("batch %d g_loss : %f" % (index, g_loss)) if index % 10 == 9: g.save_weights('generator', True) d.save_weights('discriminator', True) 互联网新技术在线教育领航者

39.GAN 图片生成 生成 LOGO def generate(BATCH_SIZE, nice=False): g = generator_model() g.compile(loss='binary_crossentropy', optimizer="SGD") g.load_weights('generator') noise = np.random.uniform(-1, 1, (BATCH_SIZE, 100)) generated_images = g.predict(noise, verbose=1) image = combine_images(generated_images) image = image*127.5+127.5 Image.fromarray(image.astype(np.uint8)).save( "generated_image.png") 互联网新技术在线教育领航者

40.GAN LOGO • GAN简介 • GAN预备知识 • GAN网络实战分析 • 生成手写数字 demo分析 • 常见其他网络和改进策略 互联网新技术在线教育领航者

41.GAN 如何输出指定类的输出 CGAN LOGO GAN与CGAN的区别 互联网新技术在线教育领航者

42.GAN 如何输出指定类的输出 CGAN LOGO CGAN Conditional Generative Adversarial Nets y不一定是指定类的输出,可以是一些条件 这是GAN生成太自由的解决方案 互联网新技术在线教育领航者

43.DCGAN LOGO 卷积神经网络和对抗神经网络结合起来的一篇经典论文 核心要素:在不改变GAN原理的情况下提出了一些有助于增强稳定性的tricks DCGAN:deep convolutional generative adversarial networks 互联网新技术在线教育领航者

44.DCGAN论文使用的tricks LOGO • 所有pooling都用strided convolutions代替,pooling的下采样是损失信息的, strided convolutions可以让模型自己学习损失的信息 • 生成器G和判别器D都要用BN层 • 把全连接层去掉,用全卷积层代替 • 生成器除了输出层,激活函数统一使用ReLU。输出层用Tanh。 • 判别器所有的层的激活函数统一都是LeakyReLU 互联网新技术在线教育领航者

45.DCGAN论文中的一些结果展示 LOGO 互联网新技术在线教育领航者

46.GAN的各种结构变种 ACGAN LOGO Conditional Image Synthesis with Auxiliary Classifier GANs 互联网新技术在线教育领航者

47.infoGAN LOGO • D网络的输入只有x,不加c • Q网络和D网络共享同一个网络,只是到最后一层独立输出 InfoGAN: Interpretable Representation Learning by Information Maximizing Generative Adversarial Nets http://www.tk4479.net/hjimce/article/details/55657325 互联网新技术在线教育领航者

48.LAPGAN LOGO 生成 训练 互联网新技术在线教育领航者

49.EBGAN Energy-based GAN LOGO 生成器和判别器的损失函数 《Energy-based Generative Adversarial Network》- Junbo Zhao , arXiv:1609.03126v2 互联网新技术在线教育领航者

50.EBGAN Energy-based GAN LOGO 解决多样性问题 互联网新技术在线教育领航者

51.GAN LOGO 你以为解决了所有问题了么?too young 互联网新技术在线教育领航者

52.GAN LOGO https://www.jiqizhixin.com/articles/2017-03-27-4 互联网新技术在线教育领航者

53.GAN 稳定,多样性,清晰度 LOGO • G,D迭代的方式能达到全局最优解么? 大部分情况是局部最优解 • 不一定收敛,学习率不能高,G,D要共同成长,不能其中一个成 长的过快 • 崩溃的问题,通俗说,G 找到 D的漏洞,每次都生成一样的骗 D • 无需预先建模,模型过于自由,不可控 判别器训练得太好,生成器梯度消失,生成器loss降不下去; 判别器训练得不好,生成器梯度不准,四处乱跑。 https://zhuanlan.zhihu.com/p/25071913 互联网新技术在线教育领航者

54. GAN 稳定,多样性,清晰度 LOGO Theorem 1. The global minimum of the virtual training criterion C(G) is achieved if and only if pg = pdata. At that point, C(G) achieves the value log4. Generative Adversarial Nets 互联网新技术在线教育领航者

55.GAN 稳定,多样性,清晰度 LOGO • “生成器没能生成真实的样本” 惩罚小 • “生成器生成不真实的样本” 惩罚大 偏向于生成“稳妥”的样本 https://zhuanlan.zhihu.com/p/25071913 互联网新技术在线教育领航者

56.WGAN Wasserstein GAN LOGO • 判别器最后一层去掉sigmoid • 生成器和判别器的loss不取log • 每次更新判别器的参数之后把它们的绝对值截断到不超过一个固定常数c • 不要用基于动量的优化算法(包括momentum和Adam),推荐RMSProp,SGD也行 GAN WGAN 用Wasserstein距离代替KL散度,训练网络稳定性大大增强,不用拘泥DCGAN的那些策略 互联网新技术在线教育领航者

57.WGAN-GP WGAN with gradient penalty LOGO 不截断了,只对梯度增加惩罚项 WGAN_GP 一度成为state of the art 互联网新技术在线教育领航者

58.DRAGAN Deep Regret Analytic GAN LOGO 谁说GAN就不如WGAN,加上gradient penalty,大家效果都差不多 https://arxiv.org/pdf/1705.07215.pdf 互联网新技术在线教育领航者

59.DRAGAN Deep Regret Analytic GAN LOGO DRAGAN WGAN-GP https://arxiv.org/pdf/1705.07215.pdf 互联网新技术在线教育领航者

60.GAN 的其他典型LOSS优化变种 LOGO 论文的小笔误,应该是=- 《Are GANs Created Equal? A Large-Scale Study》 互联网新技术在线教育领航者

61.GAN 方案比较 LOGO Google Brain:Are GANs Created Equal? A Large-Scale Study FID:Fre ́chet Inception Distance https://arxiv.org/pdf/1706.08500.pdf FID F1, recall, precision 结论:特定的数据集说特定的事情,没有哪一种碾压其他。好的算法还得看成本,时间短的效果某家强 ,但是训练时间长了,反倒会变差。根据评价标准的不同,场景的不同,效果差的算法也可以逆袭。 互联网新技术在线教育领航者 https://www.jiqizhixin.com/articles/2017-11-30-6

62.QA 62