Machine Learning in R: Neural Network Using Keras on MNIST Dataset

In this project, you will learn how to create and train a Neural Networks to build a classifier that can recognise and classify images of hand-written digits in one of the 10 classes (for digits 0 to 9) from the very popular MNIST dataset! This is the same underlying technology used in modern Object Recognition applications including Face Recognition and Identification.

Join for Free
Machine Learning in R: Neural Network Using Keras on MNIST Dataset

Duration (mins)


5.0 / 5


Task List

We will cover the following tasks in 31 minutes:


In this introductory task, we will discuss Neural Networks. I’ll give you a quick history of Machine Learning. I’ll introduce you to the Rhyme Interface, and finally share a little bit about myself.


In this task, we will start by looking at a visual representation of a Tensor. A Tensor is a lot like a multi-dimensional array. We will then move on to create 60,000 Tensors, each with a shape corresponding to our image size in order to create our dataset. We will do this by using the array_reshape function in Keras.

One Hot Encoding

ML algorithms generally need categorical data in what are called “One Hot” encodings. In this encoding, numeric class representations are converted to label vectors whose dimension correspond to the total number of classes given in the dataset. In this task, I will show you how to encode our labels in such a way with a simple function.

Building the Model

In this task we are going to build the architecture for the model. We will be using ReLU (Rectified Linear Unit) activation function, which is one of the most used activation functions right now in Deep Learning, on our hidden layers. We will use the Softmax function as the final layer activations of our neural network-based classifier, which is also very popular when it comes to classifiers. Let’s see how this is done!

Loss Optimizer and Model Run

We need to use a loss optimizer so we can spot when the model starts over-fitting to the training data. We will be using a categorical cross-entropy loss function as our loss function - this is representative of the mistakes the model makes in predicting labels over the training data. Cross-entropy loss increases as the predicted probability diverges from the actual label. As the model trains, an optimization algorithm will gradually adjust values of the model’s internal parameters to try and decrease this loss value, thereby making better predictions.

Test Data and Summary

In this task we will see how the model performs on data it hasn’t seen or hasn’t been trained on. After we test the model, I will run through everything we have learned in this project and we can get on with our next project.

Watch Preview

Preview the instructions that you will follow along in a hands-on session in your browser.

Rhyme Authors

About the Host

Rhyme Authors

Frequently Asked Questions

In Rhyme, all projects are completely hands-on. You don't just passively watch someone else. You use the software directly while following the host's (Rhyme Authors) instructions. Using the software is the only way to achieve mastery. With the "Live Guide" option, you can ask for help and get immediate response.
Nothing! Just join through your web browser. Your host (Rhyme Authors) has already installed all required software and configured all data.
Absolutely! Your host (Rhyme Authors) has provided this session completely free of cost!
You can go to, sign up for free, and follow this visual guide How to use Rhyme to create your own projects. If you have custom needs or company-specific environment, please email us at
Absolutely. We offer Rhyme for workgroups as well larger departments and companies. Universities, academies, and bootcamps can also buy Rhyme for their settings. You can select projects and trainings that are mission critical for you and, as well, author your own that reflect your own needs and tech environments. Please email us at
Rhyme strives to ensure that visual instructions are helpful for reading impairments. The Rhyme interface has features like resolution and zoom that will be helpful for visual impairments. And, we are currently developing a close-caption functionality to help with hearing impairments. Most of the accessibility options of the cloud desktop's operating system or the specific application can also be used in Rhyme. If you have questions related to accessibility, please email us at
We started with windows and linux cloud desktops because they have the most flexibility in teaching any software (desktop or web). However, web applications like Salesforce can run directly through a virtual browser. And, others like Jupyter and RStudio can run on containers and be accessed by virtual browsers. We are currently working on such features where such web applications won't need to run through cloud desktops. But, the rest of the Rhyme learning, authoring, and monitoring interfaces will remain the same.
Please email us at and we'll respond to you within one business day.

Ready to join this 31 minutes session for free?