TensorFlow for Machine Learning
TensorFlow is a widely used library in data science. Wikipedia describes Tensorflow as “a free and open-source software library for dataflow and differentiable programming across a range of tasks. It is a symbolic math library, and is also used for machine learning applications such as neural networks.”
In the paper, TensorFlow: A System for Large-Scale Machine Learning, published by the Google Brain in 2016, a more comprehensive description of TensorFlow is provided: https://www.usenix.org/system/files/conference/osdi16/osdi16-abadi.pdf
Abstract: TensorFlow is a machine learning system that operates at large scale and in heterogeneous environments. TensorFlow uses dataflow graphs to represent computation, shared state, and the operations that mutate that state. It maps the nodes of a dataflow graph across many machines in a cluster, and within a machine across multiple computational devices, including multicore CPUs, generalpurpose GPUs, and custom-designed ASICs known as Tensor Processing Units (TPUs). This architecture gives flexibility to the application developer: whereas in previous “parameter server” designs the management of shared state is built into the system, TensorFlow enables developers to experiment with novel optimizations and training algorithms. TensorFlow supports a variety of applications, with a focus on training and inference on deep neural networks. Several Google services use TensorFlow in production, we have released it as an open-source project, and it has become widely used for machine learning research. In this paper, we describe the TensorFlow dataflow model and demonstrate the compelling performance that TensorFlow achieves for several real-world applications.
I am interested in TensorFlow simply because I missed a meetup event two years ago when google organized a training for using TensorFlow for machine learning in Kirkland. That was my first time heard about TensorFlow. I registered the event, but because some conflict occurred, I did not make it. At that time, I was interested in machine learning and started listening some lectures on the youtube. Nevertheless, I did not dig in too much but only gained some conceptual understanding about machine learning.
Now, I am a student in the data science program at Flatiron school and our next module is Machine Learning. I want to learn more about TensorFlow because I believe it will be very useful for machine learning.
After a brief recall of the personal relationship with TensorFlow, let me get to know her more comprehensively.
TensorFlow was the successor of DistBlief, a machine learning system built based on deep learning neural networks in Google for internal research and commercial application. TensorFlow simplified and refactored the codebase into a more robust application-grade library, with higher accuracy.
Machine Learning are used by a diverse community of Developers, enterprises and researchers to solve real world problems. Their work has been powered by TensorFlow for a few main advantages of TensorFlow.
Firstly, TensorFlow enables easy model building. TensoreFlow applies intuitive high-level APIs such as Keras to build and train ML models. In this way, it is easy for immediate model iteration and debugging.
Secondly, TensorFlow is very flexible and allows easily train and develop models in the cloud, on-prem, in the browser, or on-device with different language. This advantage makes TensorFlow a universal tool for developing ML model.
Thirdly, a simple and flexible architecture in TensorFlow fastens the process of experimentation for research.
Because of these advantages of TensorFlow, it has gained worldwide application in ML in various domains to solve challenging problems. Companies that use TensorFlow includes Google, Airbnb, Intel, GE Healthcare, Twitter, and so forth. Since March 2019 when Google released its TensorFlow Machine Learning courses, a diverse community of TensorFlow has earned popularity quickly. People share works, thoughts, and help each other regarding the application of Tensor. There are rich resources, such as courses, articles, discussions, conference talk videos on the TensorFlow community website: https://www.tensorflow.org. On the TensorFlow website, there are videos that exemplify using ML, deep learning and TensorFlow to detect respiratory diseases, better predicting extreme weather, and so forth. I believe it will become my BEST friend soon.
I went through a basic ML class offered on the TensorFlow Website, Basic classification: Classify images of clothing. (https://www.tensorflow.org/tutorials/keras/classification). It was a very pleasant learning experience of using TensorFlow for conducting basic classification.
The classification model uses the Fasion-MNIST data, which is a dataset of Zalando’s article images — consisting of a training set of 60,000 examples and a test set of 10,000 examples. This dataset has been used by the community of data science as a benchmark to validate their algorithms.
After download the data, the author guides us through a very clear and wholistic classification case using Tensorflow.keras. The first step is to explore the data to understand the dataset. Second, processed the data by scaling the data values to a range of 1 to 1 for both training and test datasets for the neural network. The author also tried to make sure that the format is correct for the model.
After the preparation of the data, the author started building the model. Setting up the layers goes first since the basic building block of a neural network is the layer. The, here comes the compiling the model, which includes three steps:
- Loss function — This measure how accurate the model is during training.
- Optimizer — This is how the model is updated on the data it sees and its loss function.
- Metrics — Used to monitor the training and testing steps.
The next step is the most exciting part, train the model: which includes feed the model, evaluate the accuracy, make predictions, and verify predictions.
Finally, use the trained model to make a prediction about the single image.
The whole process is very concise by using keras.Sequential to build the model, using model.fit to fit the model to the training data, and using the model.evaluate to compare how the model performs on the test dataset.
This example demonstrate the high level architecture of the TensorFlow that simply the code and fasten the modeling. As stated on the TensorFlow website, TensorFlow enables users to build and train state-of-the-art models without sacrificing speed or performance.
I look forward to applying TensorFlow in my next module and in my future work frequently!
For further understanding of TensorFlow, here is an article Google Brain published in 2016. https://www.usenix.org/system/files/conference/osdi16/osdi16-abadi.pdf
References:
wikipedia: https://en.wikipedia.org/wiki/TensorFlow
TensorFlow Website: https://www.tensorflow.org/about
Fashion-MNIST: https://github.com/zalandoresearch/fashion-mnist