Build a Neural Network

by enlight

An introduction to building a basic feedforward neural network with backpropagation in Python.

Machine Learning / Python / Intermediate

Tutorial Dependencies

<aside> šŸ’” Before you start building a neural network, you should probably be familiar with basic python. There are also some basic concepts of linear algebra and calculus involved. If you aren't there yet, it's all good! Go through these tutorials first and come back when you're ready!

</aside>

Introduction

Understanding the Process

Before we get started with theĀ howĀ of building a Neural Network, we need to understand theĀ whatĀ first.

Neural networks can be intimidating, especially for people new to machine learning. However, this tutorial will break down how exactly a neural network works and you will have a working flexible neural network by the end. Letā€™s get started!

With approximately 100 billion neurons, the human brain processes data at speeds as fast as 268 mph! In essence, a neural network is a collection of neurons connected by synapses. This collection is organized into three main layers: the input layer, the hidden layer, and the output layer. You can have many hidden layers, which is where the term deep learning comes into play. In an artificial neural network, there are several inputs, which are called features, and a single output is produced, which is called a label.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/451c58dd-3d4e-4c9d-af5e-cb7e96365bd1/Frame_1.png

The circles represent neurons while the lines represent synapses. The role of a synapse is to multiply the inputs and weights. You can think of weights as the ā€œstrengthā€ of the connection between neurons. Weights primarily define the output of a neural network. However, they are highly flexible. After, an activation function is applied to return an output.

Hereā€™s a brief overview of how a simple feedforward neural network works. We'll be going through the following steps in the tutorial. Don't worry if some of these terms feel unfamiliar.

  1. Takes inputs as a matrix (2D array of numbers)
  2. Multiplies the input by a set weights
  3. Applies an activation function
  4. Returns an output
  5. Error is calculated by taking the difference from the desired output from the data and the predicted output. This creates our gradient descent, which we can use to alter the weights.