Introduction to Machine Learning with TensorFlow
Published: 2021-03-15 04:40:58

###Machine Learning
When we program a computer to "think" in ways that superficially resemble human thought, it's called machine learning. Machine learning is the building block of artificial intelligence, which powers auto-complete and fraud detection software as well as automated playlists and recommended videos for Spotify and YouTube. Machine learning is famously used in facial recognition software and in targeted ad algorithms.

###Complex Algebra
Recognizing images is something the human mind does effortlessly, but it takes a lot for a computer to perform the same task. Image recognition software begins with a series of neurons, which are defined as numbers ranging from 0 to 1. Whichever number a neuron holds is its activation, and the closer to 1, the more activated it is. 

We can model any grey-scale image as a matrix of neurons. Each neuron corresponds to a pixel, and its activation corresponds to its darkness of shade, with darker pixels being closer to 0 and lighter pixels being closer to 1. An AI algorithm tasked with identifying an image would start with the matrix of pixels and pass them through a series of hidden layers with progressively fewer neurons until it reaches the output layer. These layers act kind of like a game of 21 questions. The first layer may determine if the image is of a plant, animal, person, or object. If it determines it is an animal, the next layer may determine what species, and so on. In theory, the more layers involved, the more accurate the image identification will be, but each layer consumes a lot of run time memory. [3Blue1brown](https://www.youtube.com/watch?v=aircAruvnKk&ab_channel=3Blue1Brown) goes into detail about a four-layered neural network tasked with visually identifying numbers written in a wide range of styles. 

The neurons in a neural network are connected through layers with different "weights" that in turn have different "biases." Each of these terms translates to a variable in a few complex algebraic equations. Two foundational equations for machine learning are the [Sigmoid function](https://en.wikipedia.org/wiki/Sigmoid_function), represented as `s(x) = 1 / 1 + e^-x` and [ReLU](https://machinelearningmastery.com/rectified-linear-activation-function-for-deep-learning-neural-networks/) -- rectified linear unit -- represented by the simpler and more accurate equation `ReLU(a) = max(0,a)`. All of this heady math is beyond the scope of this article and above my pay-grade. Fortunately in computer science, we stand on the shoulders of giants, and there are libraries and APIs out there that give developers access to complex machine learning algorithms without all the number crunching. 

###TensorFlow

TensorFlow is an open source library developed by the Google Brain team that affords lay people the powers of machine learning. It was written in C++ and can be utilized in JavaScript or Python. You know that daunting diagram in the banner image? TensorFlow reduces the most complicated parts of that network to just a few lines of code.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3wyd8co43swi256tzpm0.png)

TensorFlow derives its name from the [tensor](https://en.wikipedia.org/wiki/Tensor) data structure that can store any number of scalers, vectors, or matrices. While TensorFlow's job is to abstract away the algebraic details of machine learning, it's important to note that an image is itself a matrix of pixels, and so machine learning can be powered by a GPU instead of a CPU. TensorFlow is accelerated by [WebGL](https://www.khronos.org/webgl/), an open-source JavaScript graphics API.    

###ml5.js
[ml5](https://ml5js.org/) is an open source library and community that builds upon the TensorFlow library. ml5 doesn't require any other dependencies besides TensorFlow, so it's surprisingly easy to get started with. You can fork this image-recognition app from their [GitHub](https://github.com/ml5js/ml5-library/tree/main/examples/javascript/ImageClassification/ImageClassification) and have the power of machine learning at your fingertips. 

###Conclusion
* Machine learning is a rapidly developing field that increasingly powers our daily lives
* Machine learning algorithms are powered by complex algebraic equations
* Open source libraries like TensorFlow and ml5 give us the power of machine learning without needing a PHD in advanced mathematics

###Sources:

* [TensorFlow in 10 Minutes](https://youtu.be/tXVNS-V39A0)
* [But what is a neural network?](https://www.youtube.com/watch?v=aircAruvnKk&ab_channel=3Blue1Brown)
* [Sigmoid Function](https://en.wikipedia.org/wiki/Sigmoid_function)
* [Tensor](https://en.wikipedia.org/wiki/Tensor)
* [Introduction to TensorFlow.js](https://www.youtube.com/watch?* v=Qt3ZABW5lD0&ab_channel=TheCodingTrain)
* [TensorFlow](https://www.tensorflow.org/js)
* [ml5](https://ml5js.org/)
* [A Gentle Introduction to the Rectified Linear Unit](https://machinelearningmastery.com/rectified-linear-activation-function-for-deep-learning-neural-networks/)
* [WebGL Overview](https://www.khronos.org/webgl/)
* [Deep Neural Networks] (https://www.kdnuggets.com/2020/02/deep-neural-networks.html)