Chapter 3: Deep Learning with Keras
Activity 3: Building a Single-Layer Neural Network for Performing Binary Classification
Solution
- Load all the required packages:
# import required packages from Keras
from keras.models import Sequential
from keras.layers import Dense, Activation
import numpy
# import required packages for plotting
import matplotlib.pyplot as plt
import matplotlib
%matplotlib inline
import matplotlib.patches as mpatches
# import the simulated dataset and the function for plotting decision boundary
from utils import load_dataset, plot_decision_boundary
- Set up a seed:
# define a seed for random number generator so the result will be reproducible
seed = 1
- Load the simulated dataset, and print the size of X and Y and the number of examples:
# load the dataset, print the shapes of input and output and the number of examples
X, Y = load_dataset()
print(“X size = “, X.shape)
print(“Y size = “, Y.shape)
print(“Number of examples = “, X.shape...