Skip to Main Content
Learning TensorFlow.js
book

Learning TensorFlow.js

by Gant Laborde
May 2021
Intermediate to advanced content levelIntermediate to advanced
338 pages
7h 44m
English
O'Reilly Media, Inc.
Content preview from Learning TensorFlow.js

Chapter 4. Image Tensors

“But he who dares not grasp the thornShould never crave the rose.”

—Anne Brontë

In the previous chapter, you created and destroyed simple tensors. However, our data was minuscule. As you might guess, printing tensors can take you only so far and in so many dimensions. You’re going to need to learn how to deal with large tensors, which are more common. This is, of course, true in the world of images! This is an exciting chapter because you’ll start working with real data, and we’ll be able to see the effects of your tensor operations immediately.

We’ll also get to utilize some existing best practices. As you recall, in the previous chapter, you converted a tic-tac-toe game to tensors. During this exercise with a simple 3 x 3 grid, you identified one method for converting a game’s state, but another person might have come up with a completely different strategy. We’ll need to identify some common practices and tricks of the trade, so you don’t have to reinvent the wheel every time.

We will:

  • Identify what makes a tensor an image tensor

  • Build some images by hand

  • Use fill methods to create large tensors

  • Convert existing images to tensors and back

  • Manipulate image tensors in useful ways

When you finish this chapter, you’ll be confident in managing real-world image data, and a lot of this knowledge will apply to managing tensors in general.

Visual Tensors

You might assume that when an image is converted into a tensor, that resulting tensor will ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Go

Learning Go

Jon Bodner
Learning Algorithms

Learning Algorithms

George Heineman
Learning Spark, 2nd Edition

Learning Spark, 2nd Edition

Jules S. Damji, Brooke Wenig, Tathagata Das, Denny Lee

Publisher Resources

ISBN: 9781492090786Errata PageSupplemental Content