Constructing a single layer neural network
A perceptron is a good start, but it cannot do much. The next step is to have a set of neurons act as a unit to see what we can achieve. Let's create a single neural network that consists of independent neurons acting on input data to produce the output.
Create a new Python file and import the following packages:
import numpy as np import matplotlib.pyplot as plt import neurolab as nl
We will use the input data from the file data_simple_nn.txt
provided to you. Each line in this file contains four numbers. The first two numbers form the datapoint and the last two numbers are the labels. Why do we need to assign two numbers for labels? Because we have four distinct classes in our dataset, so we need two bits to represent them. Let us go ahead and load the data:
# Load input data text = np.loadtxt('data_simple_nn.txt')
Separate the data into datapoints and labels:
# Separate it into datapoints and labels data = text[:, 0...