Search icon CANCEL
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
Mastering TensorFlow 1.x

You're reading from   Mastering TensorFlow 1.x Advanced machine learning and deep learning concepts using TensorFlow 1.x and Keras

Arrow left icon
Product type Paperback
Published in Jan 2018
Publisher Packt
ISBN-13 9781788292061
Length 474 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

Table of Contents (21) Chapters Close

Preface 1. TensorFlow 101 2. High-Level Libraries for TensorFlow FREE CHAPTER 3. Keras 101 4. Classical Machine Learning with TensorFlow 5. Neural Networks and MLP with TensorFlow and Keras 6. RNN with TensorFlow and Keras 7. RNN for Time Series Data with TensorFlow and Keras 8. RNN for Text Data with TensorFlow and Keras 9. CNN with TensorFlow and Keras 10. Autoencoder with TensorFlow and Keras 11. TensorFlow Models in Production with TF Serving 12. Transfer Learning and Pre-Trained Models 13. Deep Reinforcement Learning 14. Generative Adversarial Networks 15. Distributed Models with TensorFlow Clusters 16. TensorFlow Models on Mobile and Embedded Platforms 17. TensorFlow and Keras in R 18. Debugging TensorFlow Models 19. Tensor Processing Units
20. Other Books You May Enjoy

Stacked autoencoder in TensorFlow

The steps to build a stacked autoencoder model in TensorFlow are as follows:

  1. First, define the hyper-parameters as follows:
learning_rate = 0.001
n_epochs = 20
batch_size = 100
n_batches = int(mnist.train.num_examples/batch_size)
  1. Define the number of inputs (that is, features) and outputs (that is, targets). The number of outputs will be the same as the number of inputs:
# number of pixels in the MNIST image as number of inputs
n_inputs = 784
n_outputs = n_inputs
  1. Define the placeholders for input and output images:
x = tf.placeholder(dtype=tf.float32, name="x", shape=[None, n_inputs])
y = tf.placeholder(dtype=tf.float32, name="y", shape=[None, n_outputs])
  1. Add the number of neurons for encoder and decoder layers as [512,256,256,512]:
# number of hidden layers
n_layers = 2
# neurons in each hidden layer
n_neurons = [512,256]
...
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 AU $24.99/month. Cancel anytime