2. Real-World Deep Learning: Predicting the Price of Bitcoin
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.
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.
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...
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.