Things every Tensorflow beginner should know.
Machine Learning and Deep learning have become the trend and most demanding technology of the IT industry in the recent times. With the trend and demand for this domain continuously rising, platforms like tensorflow, pytorch emerged encouraging people and students to enter into the machine learning and deep learning. My experience with tensorflow started with my final year project and honestly it was not all that easy moving from scikit learn to tensorflow. I did have a difficult time as it was a long time before that I worked in scikit learn and all of a sudden I had to work in tensorflow. It was different in a few ways and it did take me a decent amount of for me to figure it out. So here are few of that things I figured out every beginner should know while using tensorflow.
Why use tensorflow?
Yeah it’ s totally obvious that this would be the first question. Among so many libraries why go for tensorflow? Well there are many reasons, I can give you few…
It’s Google, Tensorflow is a project that comes directly from Google. Created by the Google brain team, it is used by Google themselves in production. It was eventually made open source so that everyone could people could contribute and everyone could benefit from the technology. Google original machine learning platform, used in production by them, isn’t that enough to be excited about?
Parallel Computing , is one of the key reasons for using tensorflow. It provides high-level operations. Tensorflow can be configured to run in multiple processor taking advantage of all the available hardware. There is also a GPU version of tensorflow available which can be configured to use all the available GPUs in the system.
Flexibility, is an important parameter in tensorflow. It allows developers to develop their own models and functionalities for usage and also allows them to deploy these models for other usage.
Distributions for Different Platforms, are available such as Tensorflow.js for mobile, Tensorflow Lite for embedded and IOT, Tensorflow Extended for Production.
Switchable modes of operation between computational graph and eager execution, are available in tensorflow which allows for the developer to choose the best possible way of operation for their model.
That’s all I can think of now, but trust me there is a lot more to it.
What are tensors?
When you start off with any article, tutorial, course on tensorflow, you will hear these exact words “tensorflow works on objects called tensors”. You will understand it as array of arrays or list of lists but it was not really satisfying explanation from me, so I started researching. Searching will give you another set of words “a tensor is a mathematical object”. It did not really satisfy my answer hunt so I kept researching to find that they are a generalization of vectors and a system to represent a vectors in higher dimensions. Most people have never heard of tensors because it is not one of the basic representation techniques and so not really taught in schools and colleges.
Basically Tensors are a generalized representation of higher dimensional vectors and which can represent change in all the other dimension due to a single change in one dimension. I can keep talking about tensors but it deserves a write up of its own. For now let’s just stick to the very general idea.
Tensors have two parameters, dimensions and rank. Consider dimensions as the number of features in the dataset. So that is a particular number. Then for representing every single point in the dataset you will (dimension^rank) numbers to represent.
Let’s take an example to understand this. Consider a dataset where each point has three features, so it constitutes 3 dimensions. Consider a the rank to be 2, then you need (3 ^ 2) = 9 numbersto represent it. Programmatically the can be represented as array for every single point and entire collection of arrays for all points can be put in a single array. This is technically how tensorflow arranges datasets for operation.
Computational graph vs Eager execution.
You will have to choose your tutorials or your learning resources properly. Because there was an important and significant change in update. Tensorflow has two types of operation execution. Eager execution and Computational graph method.
Computational Graph
Computational Graph methods involves construction of a graph for execution of a operation. It involves all the variables in the nods and operations on edges. The program executes only after the entire graph is constructed. The advantage obtained from this type of execution is that parallel processing is made much. The graph is constructed in such a way that, most use of a variable is done at one time of use. Eager execution was available but not completely operational and not enabled by default.
Eager Execution
Eager execution is the technique used by most programming languages where an expression is evaluated as soon as it is bound to a variable. This was not part of the initial version but was introduced in tensorflow 2.0. This time eager execution was the method which was made default. This change was based on the fact that you don’t need a computational graph every time. Smaller operations can be completed without going for the strain of constructing a graph.
Tensorflow 2.0 uses eager execution as default, choose your learning resources properly based on the version, you don’t want to get lost halfway do you?
Learning Resources are right there in the official Website.
When learning something new, people surf everywhere in the internet for courses and articles. I did too until I realized everything I need was right there in the official website. So I would just say, you don’t have to hunt for a very good resource or you know do the mistake that I did wasting time searching. Everything you need tutorials, coding to videos for learning everything is available right there. Yeah you won’t find any articles or blogs there. Just for that stuff you may need to surf a little.
Documentation is key in learning any technology. The tensorflow documentation is fantastic and crystal clear. Of course its google but there is always that initial little difficulty to adjust to a new technology’s documentation. But there was no issue with me for tensorflow and could immediately adapt. So the point is there is not much to look outside. Everything is crystal clear, everything from documentation, explanation to video tutorials and are available in their official website.
Conclusion
These are a few things I had difficulties figuring out as a beginner in tensorflow, and I should be making it easy for folks like me by sharing my experiences. Hope this write up helps you. Since I am into it now, I maybe writing more on tensorflow and also making tutorials. Until next time…