Have you ever wondered whether you should implement Neural Networks (NNs) or Machine Learning (ML) algorithms from scratch in pure Python or spend some time learning how to use a Machine Learning Framework (like Caffe, PyTorch or TensorFlow)?
Well, I have used both ways to create NNs and train models using supervised and unsupervised learning methods, so I will showcase my personal view and justify my opinion using examples. If you do not know what supervised and unsupervised learning means, do not worry, I will cover that in a separate post.
First of all, let me illustrate some examples from my experience of developing NNs from scratch. I studied Computer Science in the University of Cyprus and I took their Machine Learning course, which took place between September and December 2019.
In that course, our task was to create NNs from scratch, using any programming language we wanted. More specifically, we had to implement and train Multi-Layer Perceptron NNs with Stochastic Gradient Descent (supervised learning), Kohonen-SOM NNs with and without Learning Vector Quantisation (LVQ) (unsupervised+supervised and unsupervised learning, respectively) and Radial Basis Function NNs with constant and variable centres (supervised learning). We also learned about reinforcement learning but they did not ask us to implement anything on this, because of the high complexity behind it. I have to admit, that these tasks were not hard at all because they showed us beforehand how each of the algorithms works and why (all the maths behind it).
I decided to use Python because it was one of the programming languages that I learned myself, using online courses, and I wanted to hone my coding skills in this specific language. I am sure you can find hundreds of tutorials on how to create NNs from scratch using Python, because it is a very popular programming language at the moment (of writing this post) and also very easy to learn, especially if you have just started coding. But is it a good idea to choose one of them? Before I get into that let me introduce you to my experience with machine learning frameworks.
In April 2019, I decided that I wanted my thesis project to be related with Machine Learning, even if then I did not even know what Machine Learning meant. On July 2019, I began my research on a ML problem and I took some online courses to learn more about machine learning algorithms. After studying past papers on this specific problem, I had to decide how I was going to implement my machine learning model. The idea behind my project was to combine two different approaches, that managed to achieve state of the art results, in the hope of achieving even better results. One of the problems was that for those two implementations they used a Java machine learning framework and pure Python. I could not possibly create everything from scratch and finish my project on time, so I decided to use the PyTorch framework, which uses Python, since one of the parts was already implemented in Python.
At some point during the implementation, I realised that it was not possible to combine the two algorithms and that some modifications must be made in order to combine those two algorithms. After doing some research, I found a variation of the algorithm that could make the combination possible. Long story short, I had to use the TensorFlow framework to use that approach, so I spent a few days learning how to use TensorFlow. I was really satisfied with the results from both frameworks, but I think PyTorch was more efficient. The entire project, including the research, took me about 10 months.
So with that being said, I will give you my opinion on whether you should choose machine learning frameworks or coding from scratch.
I am inclined to believe that using a machine learning framework is obviously a better choice here and let me explain why.
First, let me ask you this, why does everybody wants to re-invent the wheel? We already have most, if not all, types of neural networks and machine learning algorithms implemented in ML frameworks. If you built a neural network from scratch you are wasting time, which could be used in training your model, and what about bugs? If there are bugs in your code your model will not be able to be trained properly, or in some case you might not be able to train at all. Not to mention the hours you will spend debugging it.
Let's say you found the implementation of a machine learning algorithm, written in pure Python, on the internet and you downloaded it. Let's assume there are no bugs in that piece of code. Do you think that this implementation can outperform the implementation of Google (TensorFlow) or Facebook (PyTorch)? Of course not. In case you wonder why, is because they use C++ for most of their functions, which is a lot faster than Python. Machine learning frameworks not only are well implemented but also are more efficient, which can dramatically reduce the training time of your machine learning model. Just to give you an indication, they can turn days of training into a few hours.
What is the downside of using a machine learning framework? Well, you have to spend some time to learn how to use it. There are many online courses which teach you how to use them. You can create some awesome stuff using machine learning frameworks. For instance, I created a chatbot and a model that learns how to play the 'Flappy Bird' game indefinitely.
As a bonus tip, if you want to find a job related to machine learning, most companies ask for experience with machine learning frameworks.
コメント