Book Image

TensorFlow Deep Learning Projects

By : Alexey Grigorev, Rajalingappaa Shanmugamani
Book Image

TensorFlow Deep Learning Projects

By: Alexey Grigorev, Rajalingappaa Shanmugamani

Overview of this book

TensorFlow is one of the most popular frameworks used for machine learning and, more recently, deep learning. It provides a fast and efficient framework for training different kinds of deep learning models, with very high accuracy. This book is your guide to master deep learning with TensorFlow with the help of 10 real-world projects. TensorFlow Deep Learning Projects starts with setting up the right TensorFlow environment for deep learning. You'll learn how to train different types of deep learning models using TensorFlow, including Convolutional Neural Networks, Recurrent Neural Networks, LSTMs, and Generative Adversarial Networks. While doing this, you will build end-to-end deep learning solutions to tackle different real-world problems in image processing, recommendation systems, stock prediction, and building chatbots, to name a few. You will also develop systems that perform machine translation and use reinforcement learning techniques to play games. By the end of this book, you will have mastered all the concepts of deep learning and their implementation with TensorFlow, and will be able to build and train your own deep learning models with TensorFlow confidently.
Table of Contents (12 chapters)

Preprocessing of the corpora

The first step is to retrieve the corpora. We've already seen how to do this, but let's now formalize it in a function. To make it generic enough, let's enclose these functions in a file named corpora_tools.py.

  1. Let's do some imports that we will use later on:
import pickle
import re
from collections import Counter
from nltk.corpus import comtrans
  1. Now, let's create the function to retrieve the corpora:
def retrieve_corpora(translated_sentences_l1_l2='alignment-de-en.txt'):
print("Retrieving corpora: {}".format(translated_sentences_l1_l2))
als = comtrans.aligned_sents(translated_sentences_l1_l2)
sentences_l1 = [sent.words for sent in als]
sentences_l2 = [sent.mots for sent in als]
return sentences_l1, sentences_l2

This function has one argument; the file containing the aligned sentences from...