Machine Learning
TensorFlow
Keras
TF1
TF2

Primer on TensorFlow and Keras The past TF1 the present TF2

ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design

Introduction

In recent years, TensorFlow and Keras have emerged as two of the most popular frameworks for building and deploying deep learning models. TensorFlow, developed by Google Brain, is an open-source library for numerical computation, particularly suited for large-scale machine learning, while Keras is an API designed specifically for human usability, offering simple and consistent methods to build neural networks. This article provides an in-depth look at the evolution of TensorFlow, from its first version (TF1) to the present TensorFlow 2 (TF2), with an emphasis on the integration and development of Keras.

TensorFlow 1.x: The Beginning

Overview

TensorFlow 1.x was released in 2015 and rapidly gained the attention of developers and researchers due to its flexibility and scalability. However, with great power came a steep learning curve. TF1 relies on a low-level API that required manual graph management and session control, which could be cumbersome for new users.

Key Features of TF1

  • Static Computation Graphs: TF1 uses static computational graphs which means that you define the computation graph and then can run it multiple times. This approach returned better optimization opportunities but was difficult to work with in an interactive and dynamic way.
  • Manual Session Management: In TF1, developers had to manually create and manage sessions to run parts of the graph, which proved to be a significant overhead in terms of code complexity and debugging.

Example: Basic TensorFlow 1.x Code

Here's a simple example of how a linear regression model might be implemented using TF1:

  • Eager Execution: Unlike static graphs in TF1, TF2 uses eager execution by default. This means operations are immediately evaluated in a more intuitive, pythonic way, allowing for easier debugging and a simpler programming model.
  • Integrated Keras API: Keras is fully integrated as the official high-level API for TensorFlow. This allows the creation of models with minimal code, making development more accessible and reducing boilerplate code.
  • Removal of Sessions and Placeholders: Functions and mechanisms for executing models have been simplified, entirely removing the need for sessions and placeholders used in TF1.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design

All Rights Reserved.