Reader small image

You're reading from  The Applied TensorFlow and Keras Workshop

Product typeBook
Published inJul 2020
Reading LevelIntermediate
PublisherPackt
ISBN-139781800201217
Edition1st Edition
Languages
Right arrow
Authors (2):
Harveen Singh Chadha
Harveen Singh Chadha
author image
Harveen Singh Chadha

Harveen Singh Chadha is an experienced researcher in deep learning and is currently working as a self-driving car engineer. He is focused on creating an advanced driver assistance systems (ADAS) platform. His passion is to help people who want to enter the data science universe. He is the author of the video course Hands-On Neural Network Programming with TensorFlow.
Read more about Harveen Singh Chadha

Luis Capelo
Luis Capelo
author image
Luis Capelo

Luis Capelo is a Harvard-trained analyst and a programmer, who specializes in designing and developing data science products. He is based in New York City, America. Luis is the head of the Data Products team at Forbes, where they investigate new techniques for optimizing article performance and create clever bots that help them distribute their content. He worked for the United Nations as part of the Humanitarian Data Exchange team (founders of the Center for Humanitarian Data). Later on, he led a team of scientists at the Flowminder Foundation, developing models for assisting the humanitarian community. Luis is a native of Havana, Cuba, and the founder and owner of a small consultancy firm dedicated to supporting the nascent Cuban private sector.
Read more about Luis Capelo

View More author details
Right arrow

2. Real-World Deep Learning: Predicting the Price of Bitcoin

Overview

This chapter will help you to prepare data for a deep learning model, choose the right model architecture, use Keras—the default API of TensorFlow 2.0, and make predictions with the trained model. By the end of this chapter, you will have prepared a model to make predictions which we will explore in the upcoming chapters.

Introduction

Building on fundamental concepts from Chapter 1, Introduction to Neural Networks and Deep Learning, let's now move on to a real-world scenario and identify whether we can build a deep learning model that predicts Bitcoin prices.

We will learn the principles of preparing data for a deep learning model, and how to choose the right model architecture. We will use Keras—the default API of TensorFlow 2.0 and make predictions with the trained model. We will conclude this chapter by putting all these components together and building a bare bones, yet complete, first version of a deep learning application.

Deep learning is a field that is undergoing intense research activity. Among other things, researchers are devoted to inventing new neural network architectures that can either tackle new problems or increase the performance of previously implemented architectures.

In this chapter, we will study both old and new architectures. Older architectures have been...

Choosing the Right Model Architecture

Considering the available architecture possibilities, there are two popular architectures that are often used as starting points for several applications: Convolutional Neural Networks (CNNs) and Recurrent Neural Networks (RNNs). These are foundational networks and should be considered starting points for most projects.

We also include descriptions of another three networks, due to their relevance in the field: Long Short-Term Memory (LSTM) networks (an RNN variant); Generative Adversarial Networks (GANs); and Deep Reinforcement Learning (DRL). These latter architectures have shown great success in solving contemporary problems, however, they are slightly difficult to use. The next section will cover the use of different types of architecture in different problems.

Convolutional Neural Networks (CNNs)

CNNs have gained notoriety for working with problems that have a grid-like structure. They were originally created to classify images,...

Structuring Your Problem

Compared to researchers, practitioners spend much less time determining which architecture to choose when starting a new deep learning project. Acquiring data that represents a given problem correctly is the most important factor to consider when developing these systems, followed by an understanding of the dataset's inherent biases and limitations. When starting to develop a deep learning system, consider the following questions for reflection:

  • Do I have the right data? This is the hardest challenge when training a deep learning model. First, define your problem with mathematical rules. Use precise definitions and organize the problem into either categories (classification problems) or a continuous scale (regression problems). Now, how can you collect data pertaining to those metrics?
  • Do I have enough data? Typically, deep learning algorithms have shown to perform much better on large datasets than on smaller ones. Knowing how much data is...

Using Keras as a TensorFlow Interface

We are using Keras because it simplifies the TensorFlow interface into general abstractions and, in TensorFlow 2.0, this is the default API in this version. In the backend, the computations are still performed in TensorFlow, but we spend less time worrying about individual components, such as variables and operations, and spend more time building the network as a computational unit. Keras makes it easy to experiment with different architectures and hyperparameters, moving more quickly toward a performant solution.

As of TensorFlow 2.0.0, Keras is now officially distributed with TensorFlow as tf.keras. This suggests that Keras is now tightly integrated with TensorFlow and will likely continue to be developed as an open source tool for a long period of time. Components are an integral part when building models. Let's deep dive into this concept now.

Model Components

As we saw in Chapter 1, Introduction to Neural Networks and Deep Learning...

From Data Preparation to Modeling

This section focuses on the implementation aspects of a deep learning system. We will use the Bitcoin data from the Choosing the Right Model Architecture section, and the Keras knowledge from the preceding section, Using Keras as a TensorFlow Interface, to put both of these components together. This section concludes the chapter by building a system that reads data from a disk and feeds it into a model as a single piece of software.

Training a Neural Network

Neural networks can take long periods of time to train. Many factors affect how long that process may take. Among them, three factors are commonly considered the most important:

  • The network's architecture
  • How many layers and neurons the network has
  • How much data there is to be used in the training process

Other factors may also greatly impact how long a network takes to train, but most of the optimization that a neural network can have when addressing a business...

Summary

In this chapter, we have assembled a complete deep learning system, from data to prediction. The model created in this activity requires a number of improvements before it can be considered useful. However, it serves as a great starting point from which we will continuously improve.

The next chapter will explore techniques for measuring the performance of our model and will continue to make modifications until we reach a model that is both useful and robust.

You have been reading a chapter from
The Applied TensorFlow and Keras Workshop
Published in: Jul 2020Publisher: PacktISBN-13: 9781800201217
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.
undefined
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 $15.99/month. Cancel anytime

Authors (2)

author image
Harveen Singh Chadha

Harveen Singh Chadha is an experienced researcher in deep learning and is currently working as a self-driving car engineer. He is focused on creating an advanced driver assistance systems (ADAS) platform. His passion is to help people who want to enter the data science universe. He is the author of the video course Hands-On Neural Network Programming with TensorFlow.
Read more about Harveen Singh Chadha

author image
Luis Capelo

Luis Capelo is a Harvard-trained analyst and a programmer, who specializes in designing and developing data science products. He is based in New York City, America. Luis is the head of the Data Products team at Forbes, where they investigate new techniques for optimizing article performance and create clever bots that help them distribute their content. He worked for the United Nations as part of the Humanitarian Data Exchange team (founders of the Center for Humanitarian Data). Later on, he led a team of scientists at the Flowminder Foundation, developing models for assisting the humanitarian community. Luis is a native of Havana, Cuba, and the founder and owner of a small consultancy firm dedicated to supporting the nascent Cuban private sector.
Read more about Luis Capelo