Let’s start Deep Learning with Neural Networks.
In this tutorial you’ll learn how to make a Neural Network in tensorflow.

## Training

The network will be trained on the MNIST database of handwritten digits. Its used in computer vision.

The Mnist database contains 28x28 arrays, each representing a digit. You can view these 28x28 digits as arrays.

These are flattened, the 28x28 array into a 1-d vector: 28 x 28 = 784 numbers. You’ll see the number 784 later in the code. This is where it comes from.

This dataset is included in tensorflow by default:

## Example

### Introduction

Build a simple neural network.
First import the required modules:

Then define the model: how many nodes per hidden layer, how many classes in the dataset (10: 0 to 9) and finally the batch size.

Then define the placeholders.

All constants are defined. You can now create the neural network.
Define weights and biases. A bias is a vlue that’s added to the sums, before the activation function.

This is not the model yet, these are only random numbers.
The method tf.random_normal creates random numbers. We just made it in the shape that we need.

Lets create the model:

Values are added into layer one. The input (data) is multiplied by the weights. Then the bias is added with tf.add().
This process is repeated in each layer. (layer1 into layer2, layer2 into layer 3). Then return the output layer.

The model needs to be trained. Lets create a function for that. Make a prediction with the model, then calculate the cost variable. The cost variable measures how wrong the prediction is. This function can be called loss function.

Cost needs to be optimized, pick some optimizer for it.

Lets begin training. This is similar to the training we did on the linear regression model.

Then after training

Lets call the training function!

If you want to get a single prediction (given image, which class?):

### Neural network example

The complete code of the above description below. You can tweak the number of neurons to optimize the accuracy of the network.
(I have slightly altered it).