B.2. Basic tensor operations

Tensors wouldn’t be of much use if we couldn’t perform operations on them. TensorFlow.js supports a large number of tensor operations. You can see a list of them, along with their documentation, at https://js.tensorflow.org/api/latest. Describing every single one of them would be tedious and redundant. Therefore, we will highlight some of the most frequently used operations as examples. Frequently used operations can be categorized into two types: unary and binary. A unary operation takes one tensor as input and returns a new tensor, while a binary operation takes two tensors as its inputs and returns a new tensor.

B.2.1. Unary operations

Let’s consider the operation of taking the negative of a tensor—that is, ...

Get Deep Learning with JavaScript 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.