Chapter 3
Creating Tensors and Operations
IN THIS CHAPTER
Creating tensors with known and random values
Calling functions that transform tensors
Processing tensors with operations
In grad school, I took a course on tensor mathematics that covered the usage of tensors in electromagnetism. The professor assured us that the theory was “beautiful” and “elegant,” but we beleaguered students described the relativistic mathematics as “indecipherable” and “terrifying.”
TensorFlow’s central data type is the tensor, and happily, it has nothing to do with electromagnetism or relativity. In this book, a tensor is just a regular array. If you’re familiar with Torch’s Tensor
s or NumPy's ndarray
s, you’ll be glad to know that TensorFlow’s tensors are similar in many respects.
Unfortunately, you can’t access these tensors with regular Python routines. For this reason, the TensorFlow API provides a vast assortment of functions for creating, transforming, and operating on tensors. This chapter presents many of these functions and demonstrates how you can use them.
Creating Tensors
Just as most programs start by declaring variables, most TensorFlow applications start by creating tensors. A tensor ...
Get TensorFlow For Dummies now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.