# AI News, Train A One Layer Feed Forward Neural Network in TensorFlow With ReLU Activation

- On Wednesday, June 6, 2018
- By Read More

## Train A One Layer Feed Forward Neural Network in TensorFlow With ReLU Activation

To train our model, we need to tell the model what the correct answer is and we're going to do that by feeding in the correct answers.

import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data

However, you'll notice here that instead of having a 784-dimensional vector, we have a 10-dimensional vector.

y_ which represents the correct values that we are trying to get our neural network to learn is a 10-dimensional vector as each vector corresponds to the true probability for each of the different classes, namely 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.

Once we have defined our predictions and then the true labels, we're going to use cross entropy to compare them and to produce a numerical value of how close our answer is to the correct answer.

Because we're feeding in the raw output of the ReLU, we're going to call it tf.nn.softmax_cross_entropy_with_logits.

So what this is saying is that using the TensorFlow GradientDescentOptimizer with a learning rate of 0.001, minimize the variable that we've defined as our cross entropy.

Our cross entropy here is defined as the cross entropy between logits y and the labels y_, again with the outputs of our model and the true values.

We're going to train it for 50 steps which we'll handle just using a standard Python for loop.

What this says is from the training set, pull a new batch of 100 samples from there.

Just to show that this runs, we're going to produce this and it should return without any errors.

So just to make sure that it's doing something, we'll tell it to print out what step it's on.

import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data

cross_entropy = tf.nn.softmax_cross_entropy_with_logits(logits=y, labels=y_) train_step = tf.train.GradientDescentOptimizer(0.001).minimize(cross_entropy)

To train our model, we need to tell the model what the correct answer is and we're going to do that by feeding in the correct answers.

import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data

However, you'll notice here that instead of having a 784-dimensional vector, we have a 10-dimensional vector.

y_ which represents the correct values that we are trying to get our neural network to learn is a 10-dimensional vector as each vector corresponds to the true probability for each of the different classes, namely 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.

Once we have defined our predictions and then the true labels, we're going to use cross entropy to compare them and to produce a numerical value of how close our answer is to the correct answer.

Because we're feeding in the raw output of the ReLU, we're going to call it tf.nn.softmax_cross_entropy_with_logits.

So what this is saying is that using the TensorFlow GradientDescentOptimizer with a learning rate of 0.001, minimize the variable that we've defined as our cross entropy.

Our cross entropy here is defined as the cross entropy between logits y and the labels y_, again with the outputs of our model and the true values.

We're going to train it for 50 steps which we'll handle just using a standard Python for loop.

What this says is from the training set, pull a new batch of 100 samples from there.

Just to show that this runs, we're going to produce this and it should return without any errors.

So just to make sure that it's doing something, we'll tell it to print out what step it's on.

- On Thursday, June 20, 2019

**How To Train an Object Detection Classifier Using TensorFlow 1.5 (GPU) on Windows 10**

These instructions work for newer versions of TensorFlow too! This tutorial shows you how to train your own object detector for multiple objects using Google's ...

**Build and Train Your First TensorFlow Graph**

Video from my talk at NVIDIA's GTC DC 2016. Their hosting: and click "View Recording" “Hello, ..

**Build a TensorFlow Image Classifier in 5 Min**

Only a few days left to signup for my Decentralized Applications course! In this episode we're going to train our own image classifier to ..

**The Best Way to Prepare a Dataset Easily**

Only a few days left to signup for my Decentralized Applications course! In this video, I go over the 3 steps you need to prepare a ..

**How to use FLOYD to train your models (Deep Learning)**

Let's discuss how we can use FloydHub to train our model very simple and faster.By seeing this video you will learn how to setup your account and train your ...

**TensorFlow in 5 Minutes (tutorial)**

Only a few days left to signup for my Decentralized Applications course! This video is all about building a handwritten digit image ..

**Train an Image Classifier with TensorFlow for Poets - Machine Learning Recipes #6**

Monet or Picasso? In this episode, we'll train our own image classifier, using TensorFlow for Poets. Along the way, I'll introduce Deep Learning, and add context ...

**A Guide to Running Tensorflow Models on Android**

Only a few days left to signup for my Decentralized Applications course! Let's create an Android app that uses a pre-trained Tensorflow ..

**Train an Image Classifier in 3 Minutes**

Using Tensor Flow and Docker, this tutorial will show you how to create an image classifier that can accurately identify any object in an image. Step 1 Stand Up a ...

**Intro - TensorFlow Object Detection API Tutorial p.1**

Hello and welcome to a miniseries and introduction to the TensorFlow Object Detection API. This API can be used to detect, with bounding boxes, objects in ...