Chapter 12: Custom Models and Training with TensorFlow

Will Toth
3 min readJun 21, 2021

--

A Review of Hands-On Machine Learning with Scikit-Learn, Keras & Tensorflow by Aurélien Géron

By Cai Tjeenk Willink (Caitjeenk) — Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=15896832

Summary

Tensorflow is very similar to NumPy but it includes GPU support. Built on top of this NumPy like base are a great deal of highly optimized APIs and libraries that are optimized to work on large datasets through speed and memory performant code as well as support for distributed computing.

Using Tensorflow like NumPy

The two biggest types of tensorflow variables are tf.constant and tf.Variable. These are values ndarray like object that come built in with a lot of built in functionality for Machine Learning oriented work like math libraries and gpu supported functions. The main difference between tf.constant and tf.Variable is that tf.Variable is mutable (meaning that the value can be modified) while tf.constant is immutable. This means that tf.Variable can be used as weights in neural networks. Additionally, these datatypes play nice with NumPy but one of the key things to watch out for it that TensorFlow uses 32-bit precision compared to NumPy’s 64-bit. Beyond these two main datatypes TensorFlow supports many other data types that are worth looking into like tf.SparseTensor and tf.TensorArray.

Customizing TensorFlow

TensorFlow is designed to be highly customizable. This means that even though the development of TensorFlow isn’t always on the bleeding edge of Machine Learning you should be able to create almost any type of model you can imagine using TensorFlow through custom components. While I’m not going to get into the specific components that were built the author proves that we can really create any type of component by creating a child class that builds upon the built in classes of TensorFlow.

My Thoughts

I wish I had more time to discuss this chapter because there truly is a ton of content in here. I thought it was really great that there were so many examples in this chapter of how you actually customize TensorFlow and I am definitely going to use this book as a reference for when I come back to it. I think this chapter will also be a good chapter to come back to when I am more established in my Machine Learning practice to reacquaint myself with everything TensorFlow has to offer (because I will definitely forget a lot).

Thanks for reading!

If you have any questions or feedback please reach out to me on twitter @wtothdev or leave a comment!

Additionally, I wanted to give a huge thanks to Aurélien Géron for writing such an excellent book. You can purchase said book here (non-affiliate).

Disclaimer: I don’t make any money from any of the services referenced and chose to read and review this book under my own free will.

P.S. I apologize for the brevity I had a shocking amount of work sneak up on me. Something I never aspire to on a Sunday.

--

--

No responses yet