How to do it...

Let's see how to build a deep neural network:

  1. Create a new Python file, and import the following packages (the full code is given in the deep_neural_network.py file that is provided to you):
import neurolab as nl 
import numpy as np 
import matplotlib.pyplot as plt
  1. Let's define parameters to generate some training data:
# Generate training data 
min_value = -12 
max_value = 12 
num_datapoints = 90
  1. This training data will consist of a function we define that will transform the values. We expect the neural network to learn this on its own, based on the input and output values that we provide:
x = np.linspace(min_value, max_value, num_datapoints) 
y = 2 * np.square(x) + 7 
y /= np.linalg.norm(y) 
  1. Reshape the arrays:
data = x.reshape(num_datapoints, ...

Get Python Machine Learning Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.