RSS Amplifier

Nikhil D'Souza · Nov 20, 2017

My Journey into Machine Learning

0
Sign in to vote or save

Nikhil D'Souza · Nikhil D'Souza

I have an interest in biology and computer science. Especially since we collect so much biological data, it becomes a challenge to use that data effectively. I want to learn how to leverage machine learning because it can be used for predictive analysis and spotting trends in data. This entry is to highlight my journey into machine learning. I will be learning machine learning either with the help of the internet or my friends. You can follow my technical progress on my Github. I add comment after each line of code to help explain what’s going on.

Before learning how to code a neural network, I needed to learn how a neural network works in general. I used MIT 6.034 Artificial Intelligence Lecture 12a on Neural Nets to understand the basic components of a neural network. With this lecture, I was able to understand how forward propagation and backpropagation worked.

After learning the theory behind a neural network, I decided to learn numpy which is a library for multidimensional arrays and high-level mathematical functions. This is a great starting point for any beginner learning machine learning because it allows you to truly understand the math behind a neural network. I used iamtrask’s tutorial to learn how to code a two-dimensional and three-dimensional neural network in numpy. You can look at my code here. While other machine learning libraries have predefined methods for softmax/activation functions and backpropagation, numpy forces you to code each component by hand. To fully wrap my head around this complex topic, I used Siraj Raval’s video on Activation Functions and CS231n Lecture #4 from Stanford.

Tensorflow and Pytorch are both libraries for machine learning, and both have their pros and cons (look them up if you care). After trying out both, Pytorch seems a little bit more intuitive and easier to wrap my head around.

I made a two layer neural network, but unlike numpy the neural network had an input layer with 1000 dimensions, a hidden layer 100 dimensions, and an output layer with a one dimension. I also added a batch size since I had so many input dimensions, and a learning rate to optimize my neural network. You can look at my code here.

I was very excited after training a basic neural network, but I really wanted to apply what I had learned. What if I could use machine learning to classify handwritten digits?

MNIST is a large database of handwritten digits that is great for trying out different machine learning algorithms. With the help of Justin Francis’s MNIST tutorial I was able to train a neural network to classify handwritten digits in TensorFlow. You can look at my code here.

I came up with a function called predict which took an input of a sample digit and outputted a prediction.

After finishing my neural network, I tried out different sample digits. The network only required a couple hundred epochs for 85% accuracy. For most of the digits, the neural network worked perfectly by predicting the correct number. But then I ran into this:

When I used only 200 epochs to train my model, the prediction came out to be “6”. I can see how the model came up with 6, but the correct answer is 0. Only after 2637 epochs does the model predict the correct answer: 0.

I have a long way to go in machine learning, and that’s why I will be updating this post with my progress every so often. After I understand more of the fundamentals of neural networks, I will try to learn about Convolutional Neural Networks and Generative Adversarial Networks. I will also try to apply my knowledge to interesting examples because that’s how I like to learn.

My Journey into Machine Learning was originally published in Nikhil's Blog on Medium, where people are continuing the conversation by highlighting and responding to this story.

No posts

Read the original on nikhiljdsouza.substack.com

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.