Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Python: Advanced Guide to Artificial Intelligence

You're reading from   Python: Advanced Guide to Artificial Intelligence Expert machine learning systems and intelligent agents using Python

Arrow left icon
Product type Course
Published in Dec 2018
Publisher Packt
ISBN-13 9781789957211
Length 764 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Giuseppe Bonaccorso Giuseppe Bonaccorso
Author Profile Icon Giuseppe Bonaccorso
Giuseppe Bonaccorso
Rajalingappaa Shanmugamani Rajalingappaa Shanmugamani
Author Profile Icon Rajalingappaa Shanmugamani
Rajalingappaa Shanmugamani
Arrow right icon
View More author details
Toc

Table of Contents (31) Chapters Close

Title Page
About Packt
Contributors
Preface
1. Machine Learning Model Fundamentals FREE CHAPTER 2. Introduction to Semi-Supervised Learning 3. Graph-Based Semi-Supervised Learning 4. Bayesian Networks and Hidden Markov Models 5. EM Algorithm and Applications 6. Hebbian Learning and Self-Organizing Maps 7. Clustering Algorithms 8. Advanced Neural Models 9. Classical Machine Learning with TensorFlow 10. Neural Networks and MLP with TensorFlow and Keras 11. RNN with TensorFlow and Keras 12. CNN with TensorFlow and Keras 13. Autoencoder with TensorFlow and Keras 14. TensorFlow Models in Production with TF Serving 15. Deep Reinforcement Learning 16. Generative Adversarial Networks 17. Distributed Models with TensorFlow Clusters 18. Debugging TensorFlow Models 19. Tensor Processing Units
20. Getting Started 21. Image Classification 22. Image Retrieval 23. Object Detection 24. Semantic Segmentation 25. Similarity Learning 1. Other Books You May Enjoy Index

Simple GAN with TensorFlow


Note

You can follow along with the code in the Jupyter notebook ch-14a_SimpleGAN.

For building the GAN with TensorFlow, we build three networks, two discriminator models, and one generator model with the following steps:

  1. Start by adding the hyper-parameters for defining the network:
# graph hyperparameters
g_learning_rate = 0.00001
d_learning_rate = 0.01
n_x = 784  # number of pixels in the MNIST image 

# number of hidden layers for generator and discriminator
g_n_layers = 3
d_n_layers = 1
# neurons in each hidden layer
g_n_neurons = [256, 512, 1024]
d_n_neurons = [256]

# define parameter ditionary
d_params = {}
g_params = {}

activation = tf.nn.leaky_relu
w_initializer = tf.glorot_uniform_initializer
b_initializer = tf.zeros_initializer
  1. Next, define the generator network:
z_p = tf.placeholder(dtype=tf.float32, name='z_p', 
        shape=[None, n_z])
layer = z_p

# add generator network weights, biases and layers
with tf.variable_scope('g'):
    for i in range(0, g_n_layers...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image