Implementing a one-layer neural network
We have all of the tools needed to implement a neural network that operates on real data, so in this section, we will create a neural network with one layer that operates on the Iris
dataset.
Getting ready
In this section, we will implement a neural network with one hidden layer. It will be important to understand that a fully connected neural network is based mostly on matrix multiplication. As such, it is important that the dimensions of the data and matrix are lined up correctly.
Since this is a regression problem, we will use mean squared error (MSE) as the loss function.
How to do it...
We proceed with the recipe as follows:
- To create the computational graph, we'll start by loading the following necessary libraries:
import matplotlib.pyplot as plt import numpy as np import tensorflow as tf from sklearn import datasets
- Now we'll load the
Iris
data and...