Technical Articles

Tech Articles from your friends at Oracle and the developer community.


          What Is TensorFlow: A Complete Guide

          TensorFlow, the most popular machine learning framework amongst ML developers, is almost six years old. TensorFlow is a free and open-source software library for machine learning and artificial intelligence.

          Conversely, if you are here and you do not know what TensorFlow is, chances are you are not a machine learning engineer.

          And that's fine! This guide will be both a technical and high-level summary of what TensorFlow is and what it does for the modern developer or manager interested in the capabilities of artificial intelligence.

          What is TensorFlow? Read on to find out.

          TensorFlow dependencies

          A free and open-source software library is a collection of scripts, files, and software routines that users are free to modify, copy, and re-use without permission. TensorFlow is one such library. It was written in Python, C++, and CUDA, and is a Python-friendly open-source library.

          Now, what are machine learning and artificial intelligence, and how is TensorFlow used in this context?

          Machine Learning and Tensorflow

          Have you ever used a chatbot, a language translation app, or been suggested a show by Netflix? These processes are all powered by machine learning.

          ML is a subfield of artificial intelligence and it provides computers with the ability to learn without needing to be programmed. The term "machine learning" indicates the process where a machine can use past data to learn. In contrast, the broader term of “artificial intelligence” indicates any technology that seeks to imitate human behaviors and cognitions.

          Machine learning is a critical part of artificial intelligence technology, but ostensibly not the only part. Most AI-based technologies you see around today utilize machine learning. One MIT professor states that machine learning is the most important way artificial intelligence gets done.

          Machine learning is becoming critical for business operations like advertising and talent acquisition. Deloitte found in 2020 that nearly 67% of companies use some form of machine learning, a number expected to grow to almost 97% by the end of the following year.

          This is where TensorFlow comes in. TensorFlow is a popular machine learning framework and is thus used for numerous artificial intelligence projects.

          Artificial Intelligence and Tensorflow

          Loosely defined, artificial intelligence or AI, is the capability of technology to imitate intelligent human behavior. A famous example is DeepMind's AlphaGo. This is a computer program that plays the ancient board game Go, likely one of the most complex and nuanced board games in the world.

          To give you an idea of how complex Go is, the number of board configurations is 10^170, which is more than the atoms in the universe.

          AlphaGo was able to take down some of the world's premier professional players. It is truly a breakthrough in artificial intelligence and it is now more refined since its victories in 2015. A more powerful iteration, AlphaGo Zero, was trained using TensorFlow!

          In sum, artificial intelligence is the future. More programs like AlphaGo will supplant other processes we have in the business world today, and we should become familiar with the social, economical, and ethical implications of that.

          Neural Networks

          We just said that AlphaGo Zero was trained using TensorFlow. What does that mean?
          It means that its neural network was trained by TensorFlow.

          An artificial intelligence neural network imitates a biological neural network. What it really is is an algorithm that parses data in a way similar to how the human brain works.

          In the case of AlphaGo, it started with a basic knowledge of the rules of Go and then trained on historical games of Go with a database of 30 million moves. TensorFlow is a library that enables this, with a focus on the training and inference of deep neural networks.

          TensorFlow Guide

          What is TensorFlow, in more detail? TensorFlow is a symbolic math library based on dataflow and differentiable programming. If you need to analyze a tiny dataset, then TensorFlow is not for you. People use this library for what's called deep learning, involving massive datasets like the 30 million Go moves that AlphaGo was trained on.

          Machine learning is really based on mathematical algorithms that must be translated and executed in code. It takes a lot of time and effort to code, so people use libraries to save time. Because TensorFlow is open-source, there are tons of talented programmers contributing to the code, and everyone benefits.

          If you are interested in learning about the mathematical algorithms behind machine learning, why not check out a machine learning and mathematics textbook or take an online course?

          A Bit More Math

          This article will not get into computational theory, but you should know that TensorFlow is dealing with stateful dataflow graphs.

          A graph is "stateful" if it remembers preceding events or user interactions; this makes sense in the context of machine learning. "Dataflow" refers to directed graphs in the realm of computer programming.

          Finally, a "graph" refers to a directed graph in the realm of graph theory.

          A "tensor" is a coined term that represents a large multidimensional array of vectors. Tensors can be numbers, vectors, or matrixes.

          It so happens that TensorFlow is aptly named; an easy way to remember what it does is to think about "dataflow" as it applies to computer programming. The edges are tensors, and the nodes of the graph are mathematical operations between edges or tensors. Thus, "tensor flow.”

          TensorFlow's usage of low-level computations allows it to run using the CPU and GPU as well as other GPUs. This can make training and modeling significantly faster. TensorFlow has many versions and iterations that improve usability and even higher-level versions in case you do not want to code a neural net from scratch.

          Tensorflow and Python: Friendly Open Source Library

          What makes TensorFlow amazing is that the calculations and code are already optimized to run quickly and efficiently. This is because the calculations are performed with low-level C, enabling incredible speed. The consensus in the programming community is that low-level languages are faster in much of what they do when you compare them to similar processes in higher-level languages.

          The good thing about TensorFlow is that it is Python friendly. Python is a higher-level language and is very user-friendly with an extensive collection of open source libraries. These days, TensorFlow is usable with APIs in many languages, so you do not need to know C++ to access its incredible capabilities.

          TensorFlow Benefits

          You can use TensorFlow to hunt for new planets. You can screen for diseases across millions of patients. You can use it to beat the world's most eminent chess and Go players.

          TensorFlow is an all-encompassing go-to for machine learning experts, because not only can you use it to train machine learning algorithms, but you can also build many useful simulations using partial derivatives. You can run it on Linux, macOS, and Windows. You could also choose to run it on iOS or Android.

          TensorFlow Tips

          If you are a programmer who uses Python, you can even use pure Python to interact with it through the new TensorFlow Eager, a unique programming environment for TensorFlow. This allows you to write and debug code line by line without loading huge graphs while you compile your code. TensorFlow used to be monolingual; though today, you can run it in languages like R, C++, JavaScript, and Swift.

          These days, you can even use your browser to run TensorFlow with TensorFlow.js. Maybe try it out: just open up a new browser window and simply train and execute models in your browser.

          If you do not have a PC, no worries. You can use something like TensorFlow Lite to train models with a phone or even a Raspberry Pi. Take machine learning with you everywhere you go.

          Google also announced the production of Cloud TPUs, which are specialized hardware used for machine learning that were programmed using TensorFlow. They purport up to 180 teraflops (1 teraflop is a processor's ability to calculate a trillion floating-point operations every second). With this, you can see that TensorFlow can be used for datasets on a different scale altogether than what you are used to seeing in an Excel spreadsheet.

          Note that using TensorFlow will still require you to implement your own neural net, so it is not the most high-level machine learning library available. What you get if you do use it is speed and parallelization because you can utilize both the CPU and GPUs of your computer. If you want a high-level library, you can check out Keras or tflearn, which were both written based on TensorFlow.

          Install TensorFlow Today

          What is TensorFlow? TensorFlow is a Python-friendly open-source library for numerical computation that makes machine learning faster and easier.

          To get started, all you need to do is install Python or any other language's API, and then use that to access the library repository.

          You can learn more about Python and other developer tips at our Developer Resource Center!

          Latest content

          Explore and discover our latest tutorials

          Serverless functions

          Serverless functions are part of an evolution in cloud computing that has helped free organizations from many of the constraints of managing infrastructure and resources. 

          What is a blockchain?

          In broad terms, a blockchain is an immutable transaction ledger, maintained within a distributed peer-to-peer (p2p) network of nodes. In essence, blockchains serve as a decentralized way to store information.

          OCI CLI

          The CLI is a small-footprint tool that you can use on its own or with the Console to complete Oracle Cloud Infrastructure tasks. The CLI provides the same core functionality as the Console, plus additional commands.