May 2020
Intermediate to advanced
404 pages
10h 52m
English
Operators let you perform mathematical operations on data. TF.js provides various operations for manipulating tensors. As tensors are immutable in nature, operators don't change the data contained in the tensors—they return new tensors as results instead. You can perform binary operations, such as addition, multiplication, and subtraction, on tensors. You can even chain multiple operations. The following example shows the use of two different operators in TF.js using chaining:
const e = tf.tensor2d([[1.0, 2.0], [3.0, 4.0]]); const f = tf.tensor2d([[3.0, 4.0], [5.0, 6.0]]); const sq_sum = tf.square(tf.add(e, f));sq_sum.print();
We first created two two-dimensional tensors and assigned them to e and f. We then added them and took ...
Read now
Unlock full access