TF Function and Autograph(Part II)

“Programming is the art of algorithm design and the craft of debugging errant code.”— Ellen Ullman

“Building technical systems involves a lot of hard work and specialized knowledge: languages and protocols, coding and debugging, testing and refactoring.” — Jesse James Garrett

TF function

A new way of writing TF code
  • First what are graphs?
  • What is dataflow?
  • Parallelism. By using edges to represent dependencies between operations, it is easy for the system to identify operations that can execute in parallel.
  • Distributed execution. By using edges to represent the values that flow between operations, it is possible for TensorFlow to partition your program across multiple devices (CPUs, GPUs, and TPUs) attached to different machines. TensorFlow inserts the necessary communication and coordination between devices.
  • Compilation. TensorFlow’s XLA compiler can use the information in your dataflow graph to generate faster code, for example, by fusing together adjacent operations.
  • Portability. The dataflow graph is a language-independent representation of the code in your model. You can build a dataflow graph in Python, store it in a SavedModel, and restore it in a C++ program for low-latency inference.
  • No more to run your code, you can just run it like normal python code.
  • No more tf.global_variables_initializer.


The hidden hero that acts in the dark
I’m not responsable for any damage to your brain if you choose to inspect the code generated.


  • TF function lets you leverage normal python function and all of its features, on top of that it creates the dataflow graph automatically for you, which is needed to execute operations in parallel, distribute operation loads to(CPUs, GPUs or TPUs),
  • TF function also improves the speed with which your functions execute by a factor of 10 and with the dataflow graph you can run your model in any device.
  • Autograph is a library deeply integrated with TF function that takes converts all you control flow code(if, while, for, etc…) that use or depend on any tensor into a graph for you, by rewriting everything in graph optimized code so it can run dynamically in the graph.

This article is part of a series where I will be sharing the highlights of the TF Dev Summit ’19 and surprise spin-off article that I will share a new AI race.




Computer Engineering Student, Web Dev. & AI/ML dev

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Basics of A/B testing and its use cases.

Deep NLP: Sequential Models with RNNs

TensorFlow Extended (TFX): Real World Machine Learning in Production

Lessons learned from client Machine Learning projects

Email Assistant Powered by GPT-3

Mask Optimization using GAN

KaoKore: Exploring the Intersection of Humanities and ML Research through a Japanese Art Dataset

Limited Time offer —Win USD 1200 and a Machine Learning Badge.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Prince Canuma

Prince Canuma

Computer Engineering Student, Web Dev. & AI/ML dev

More from Medium

Metric Learning for Steel Surface Classification — Part 1

Coils of hot-rolled stainless steel after rolling.

What If The Systems Recommend Clothes For You To Purchase According To The Season?

Recognize Genshin Impact’s character with CNN and Clusterization

Training a Computer Vision Model on VertexAI (with and without Explanable option)