## MNIST Dataset in CNNThe MNIST ( The MNIST dataset has The So, we have only dealt with data which contains simple data points on a The MNIST dataset is a multilevel dataset consisting of 10 classes in which we can classify numbers from 0 to 9. The major difference between the datasets that we have used before and the MNIST dataset is the method in which MNIST data is inputted in a neural network. In the perceptual model and linear regression model, each of the data points was defined by a simple x and y coordinate. This means that the input layer needs two nodes to input single data points. In the MNIST dataset, a single data point comes in the form of an image. These images included in the Here, we will see how to create a function that is a model for recognizing handwritten digits by looking at each pixel in the image. Then using TensorFlow to train the model to predict the image by making it look at thousands of examples which are already labeled. We will then check the model's accuracy with a test dataset.
**Training Data (mnist.train) -55000 datapoints****Validation Data (mnist.validate) -5000 datapoint****Test Data (mnist.test) -10000 datapoints**
Now before we start, it is important to note that every data point has two parts: an image (x) and a corresponding label (y) describing the actual image and each image is a 28x28 array, i.e., 784 numbers. The label of the image is a number between 0 and 9 corresponding to the TensorFlow MNIST image. To download and use MNIST dataset, use the following ## Softmax Regression in TensorFlowThere are only ten possibilities of a TensorFlow MNIST to be from 0 to 9. Our aim is to look at an image and say with the particular probability that a given image is a particular digit. Softmax is used when there is a possibility as the regression gives us values between 0 and 1 that sum up to 1. Therefore, our approach should be simple. We classify a TensorFlow MNIST image to be in a specific class and then represent it as a probability of being correct or not. Now, it's totally up to all objects in a particular class, and we can do a weighted sum of the pixel intensities. We also need to add a bias to concur that some things are more likely independent of the input. Softmax normalizes the weights and adds them hypothesis has a negative or a zero weight. ## Implementation of MNIST Dataset in TensorFlowThe benefit of using TensorFlow MNIST dataset classification is that it lets us describe a graph of interacting operations that run entirely outside Python. First, we import the TensorFlow library using Then we create a placeholder, a value that we'll input when we ask the library to run a computation using We should then add weights and biases to our model. Using Variable, which is a modifiable tensor that has a scope in the graph of interacting operations. Notice that shape of W is [784, 10] as we want to produce 10- dimensional vectors of evidence for different classes by multiplying 784-dimensional image vectors by it. We can add b to the output as it has a shape of [10]. ## TensorFlow MNIST- TrainingWe define a model by multiplying the feature matrix with the weight and add a bias to it, then running it through a softmax function. We use a cost function or a mean squared error function to find the deviation of our results from the actual data. The less the error, the better is the model. Another very common function is the cross-entropy when measures how inefficient our predictions are. The function is described below, where y represents the predictions and y' is the actual distribution. We implement it by adding a placeholder. Then defining the cross-entropy by Now that we have successfully defined our model, it's time to train it. We can do this with the help of gradient descent and backpropagation. There are many other optimization algorithms available as well, such as logistic regression, dynamic relaxation, and many more. We can use gradient descent with a learning rate of 0.5 for cost function optimization. Before training, we need to start a session and initialize the Variable we created earlier. This starts an interactive session and variables are initialized by Now, we have to train the network. We should change the number of epochs to suit our model. ## Checking Accuracy with Test DatasetWe check the accuracy by comparing our results with a test dataset. Here, we can make use of tf.argmax function, which lets us know the index of the highest value in a tensor along a particular axis. This gives us the list of Booleans, and then we take the mean after converting to floating-point numbers. Then, we can print out the accuracy by |

For Videos Join Our Youtube Channel: Join Now