Machine Learning (ML) is a sought-after skill in today’s automated world. Google is one of the key players in the Machine Learning space. With the growing scale and popularity of deep learning, the limitations of a single machine become more and more pronounced.
Training a model on a single computer can take a long time—the more data you have, the longer it takes. However, deep neural network require large training data sets to reach superhuman performance levels in many tasks. Without using large training data, the quality of the models tends to be low.
- However, who has time to wait for hours and hours only to train a single model and check its prediction accuracy?
- Wouldn’t it be better to reduce latency by leveraging a distributed architecture that combines the power of CPUs and GPUs?
Here’s a short visual overview of the system architecture:
TensorFlow provides a high-level ML code library. Data scientists simply write code using the operations provided by the library. The TensorFlow system transforms this code into a data flow graph. Then it distributes the data flow graph to multiple machines and executes it in a distributed manner.
The data flow graph consists of operations and tensors.
- Each operation transforms ingoing to outgoing tensor data.
- Tensors are arrays or matrices of primitive data values. An example is the matrix multiplication operation. It receives two ingoing 2D matrices (tensors) and multiplies those to get the outgoing tensor.
TensorFlow provides hardware implementations for each abstract operation. The hardware implementation is denoted as a kernel. An operation may have different kernels for different hardware such as GPUs and CPUs.
Installing TensorFlow in Python
The main language to program against the TensorFlow API is Python. Here’s how you can install a CPU-only version of TensorFlow. Type this in your terminal or command-line to install a CPU-only version on your computer:
$ pip install tensorflow-cpu
If you want to have GPU support, you’ll need to install the full tensorflow distro:
$ pip install tensorflow
If you want to install TensorFlow in PyCharm, use the full installation guide available here.
Your First TensorFlow Program
Let’s assume you’ve installed TensorFlow on your computer or in your virtual environment.
Now, you can run the first hello-world program in your Python script. Here’s the program in an interactive mode:
>>> import tensorflow as tf >>> tf.add(40, 2).numpy() 42 >>> hello = tf.constant('Hi TensorFlow!') >>> hello.numpy() b'Hi TensorFlow!'
Congratulations, you’ve written your first TensorFlow program!
Here’s a video provided by the TensorFlow core team—it’s a great way to start your learning journey!
And, as long as we’re on it—let’s dive into the second video in this series that’s as helpful as the first one. Thanks, TensorFlow team!
In this guide, you’ve taken your first steps towards TensorFlow proficiency. It’s a very valuable skill to have in the 21st century. Let’s dive deeper into the topic with the following resources.
The official TensorFlow repository provides the following helpful resources:
- TensorFlow Tutorials
- TensorFlow Official Models
- TensorFlow Examples
- DeepLearning.AI TensorFlow Developer Professional Certificate
- TensorFlow: Data and Deployment from Coursera
- Getting Started with TensorFlow 2 from Coursera
- Intro to TensorFlow for A.I, M.L, and D.L from Coursera
- Intro to TensorFlow for Deep Learning from Udacity
- Introduction to TensorFlow Lite from Udacity
- Machine Learning with TensorFlow on GCP
- TensorFlow Codelabs
- TensorFlow Blog
- Learn ML with TensorFlow
- TensorFlow Twitter
- TensorFlow YouTube
- TensorFlow Roadmap
- TensorFlow White Papers
- TensorBoard Visualization Toolkit
While working as a researcher in distributed systems, Dr. Christian Mayer found his love for teaching computer science students.
To help students reach higher levels of Python success, he founded the programming education website Finxter.com. He’s author of the popular programming book Python One-Liners (NoStarch 2020), coauthor of the Coffee Break Python series of self-published books, computer science enthusiast, freelancer, and owner of one of the top 10 largest Python blogs worldwide.
His passions are writing, reading, and coding. But his greatest passion is to serve aspiring coders through Finxter and help them to boost their skills. You can join his free email academy here.