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
Building Machine Learning Systems with Python

You're reading from   Building Machine Learning Systems with Python Explore machine learning and deep learning techniques for building intelligent systems using scikit-learn and TensorFlow

Arrow left icon
Product type Paperback
Published in Jul 2018
Publisher
ISBN-13 9781788623223
Length 406 pages
Edition 3rd Edition
Languages
Arrow right icon
Authors (3):
Arrow left icon
Luis Pedro Coelho Luis Pedro Coelho
Author Profile Icon Luis Pedro Coelho
Luis Pedro Coelho
Willi Richert Willi Richert
Author Profile Icon Willi Richert
Willi Richert
Matthieu Brucher Matthieu Brucher
Author Profile Icon Matthieu Brucher
Matthieu Brucher
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Getting Started with Python Machine Learning FREE CHAPTER 2. Classifying with Real-World Examples 3. Regression 4. Classification I – Detecting Poor Answers 5. Dimensionality Reduction 6. Clustering – Finding Related Posts 7. Recommendations 8. Artificial Neural Networks and Deep Learning 9. Classification II – Sentiment Analysis 10. Topic Modeling 11. Classification III – Music Genre Classification 12. Computer Vision 13. Reinforcement Learning 14. Bigger Data 15. Where to Learn More About Machine Learning 16. Other Books You May Enjoy

LSTM for image processing

Let's imagine we want to perform handwriting recognition. From time to time, we get a new column of data. Is it the end of a letter? If yes, which one? Is it the end of a word? Is it punctuation? All these questions can be answered with a recurrent network.

For our test example, we will go back to our 10-digit dataset and use LSTMs instead of convolution layers.

We use similar hyperparameters:

import tensorflow as tf
from tensorflow.contrib import rnn

# rows of 28 pixels
n_input=28
# unrolled through 28 time steps (our images are (28,28))
time_steps=28

# hidden LSTM units
num_units=128

# learning rate for adam
learning_rate=0.001
n_classes=10
batch_size=128

n_epochs = 10
step = 100

Setting up training and testing data is almost similar to our CNN example, except for the way we reshape the images:

import os
import numpy as np

from sklearn.datasets import fetch_mldata...
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 €18.99/month. Cancel anytime