#007 TF 2.0 An implementation of a Shallow Neural Network in tf.keras – Spirals dataset

#007 TF 2.0 An implementation of a Shallow Neural Network in tf.keras – Spirals dataset

Highlights: In this post we will see how we can classify a spirals dataset with a shallow neural network implemented in TensorFlow 2.0.

Tutorial Overview:

  1. Imports and Dataset preparation
  2. Building a Neural Network
  3. Visualization

1. Dataset: import and preparation

Let’s start by importing libraries that we will need in our code.

Last time we were using a function from sklearn to create a dataset. Now we are going to make our dataset from scratch. First, we will make a function, and then apply it. In addition, we will split our dataset on training and test subsets.

Let’s now see how it looks like and what are the shapes of our data.

2. Building a Neural Network

After all data preparation, we can create a neural network to solve the problem. Last time we were using the network with 1 hidden layer, but this time we need to make it a bit more complicated. Let’s add one more hidden layer.

After creating a model, we need to train its parameters to make it powerful. This is the next step. When the model is trained, we can evaluate it to see the accuracy and loss values. Next, we will also make some predictions.


3. Visualization

Let’s now visualize the outputs of our neural network.


In the next post we will learn how to perform classification with a shallow neural network on the MNIST Dataset Using TensorFlow 2.0.

More resources on the topic: