TensorFlow is a powerful tool for building and training neural networks. This tutorial will show you how to build a basic feed forward neural network in TensorFlow.

Click to see video:

## Introduction to TensorFlow

feedback network or FNN) is a neural network where connections between units do not form a cycle. That is, it consists of input and output layers, as well as (possibly) multiple hidden layers in between them, with no feedback loops.

## What is a Feed Forward Neural Network?

A feed forward neural network is a neural network where connections between the nodes do not form a cycle. This is different from a recurrent neural network, where connections between nodes form a directed graph with cycles.

The term “feed forward” comes from the fact that data travels through the network only in one direction,289 from the input nodes to the output nodes. There are no loops in the network.

Feed forward neural networks can have one or more hidden layers. A hidden layer is a layer of nodes that is not directly connected to the input or output layers. Data travels through the hidden layer(s) and then to the output layer.

The number of hidden layers and the number of nodes in each hidden layer can be different for each feed forward neural network.

## TensorFlow Feed Forward Neural Network Tutorial

This tutorial is intended for readers who are new to both machine learning and TensorFlow. After completing this tutorial, you will know how to implement a simple, fully connected feed forward neural network using TensorFlow. You will also be able to train this neural network to achieve good performance on a variety of tasks.

Before starting this tutorial, it is recommended that you have a basic understanding of artificial neural networks (ANNs). If you are not familiar with ANNs, we recommend that you read our Introduction to Artificial Neural Networks tutorial before proceeding.

In addition to ANNs, this tutorial also makes use of the following concepts:

-TensorFlow: an open-source software library for numerical computation that is widely used in machine learning projects.

-Feed forward neural networks: a type of ANN where information flows through the network in only one direction, from input to output.

## Building the Network

In this tutorial, we’ll be building a basic feed forward neural network in TensorFlow. This network will have a input layer, hidden layer, and output layer. We’ll be using the MNIST dataset to train our network. The MNIST dataset consists of images of handwritten digits, and our goal is to train our network to recognize these digits.

First, we’ll need to import the TensorFlow library:

import tensorflow as tf

Next, we’ll need to specify the size of our input layer. The MNIST dataset consists of images that are 28×28 pixels, so our input layer will have 784 neurons. We’ll also need to specify the size of our output layer. Since we want our network to recognize 10 different digits (from 0 to 9), our output layer will have 10 neurons.

Now we can define our placeholders for our input and output data:

x = tf.placeholder(tf.float32, shape=[None, 784]) #input data

y_ = tf.placeholder(tf.float32, shape=[None, 10]) #output data (labels)

## Training the Network

You can think of training a feedforward neural network as learning a function that maps some inputs X to some desired outputs Y. In very simple terms, the goal is to find values for the weights and biases so that when you give the network an input it will produce an output that is as close as possible to the desired output.

To do this we need a set of training data, which consists of pairs of inputs and desired outputs. We then use a technique called gradient descent to iteratively adjust the weights and biases in such a way that the error (the difference between the actual output and the desired output) is minimized.

## Evaluating the Network

Once we have trained our network, we need to evaluate it to see how it performs on data it has never seen before.

We will use the test data set for this. The test data set is similar to the training data set, but it does not contain the labels. This means that the network will have to predict the labels.

To evaluate the network, we will use the accuracy measure. This measures how many of the predicted labels are correct.

First, we need to get predictions from the network. We can do this by using the predict() function. This takes an array of inputs and returns an array of predictions:

predictions = model.predict(inputs)

Next, we need to compare the predictions to the true labels. We can do this using the NumPy equal() function:

correct_predictions = np.equal(predictions, targets)

## Conclusion

We have now built a basic feed forward neural network in TensorFlow. We’ve seen how to build the computation graph, initialize variables, and train the model. In the next tutorial, we’ll see how to improve this model by adding hidden layers.

## Further Reading

If you’re looking for more information on feed forward neural networks, or ways to optimize your TensorFlow code, we’ve compiled a list of resources that may be helpful.

– Check out the official TensorFlow documentation on [building neural networks](https://www.tensorflow.org/tutorials/sequences/sequences_and_prediction)

– Understand the basics of [activation functions](https://medium.com/the-theory-of-everything/understanding-activation-functions-9afcbf2079fb) and how they’re used in feed forward neural networks

– Learn about different [optimizers](https://www.tensorflow.org/api_guides/python/train#Optimizers) available in TensorFlow, and how to use them

– Get Tips for [debugging TensorFlow models](https://www.tensorflow.org/programmers_guide/debugger)

## Credits

This tutorial was originally created by Aymeric Damien.

It has been edited by Denny Britz for readability, clarity, and comprehensiveness.

## About the Author

I am a Data Scientist and I like to work on various problems related to Machine Learning, Deep Learning and Natural Language Processing. I have also worked on projects related to Time Series Forecasting, Anomaly Detection, and Image Classification.

Keyword: TensorFlow Feed Forward Neural Network Tutorial