Tensor Operations

Overview


Addition


Two tensors of compatible shapes can be added element by element.


let input = tf.tensor([[1, 2, 1, 1]]);
let input2 = tf.tensor([[5, 2, 1, 1]]);

let test = input.add(input2);
				
Try it!

Argmax


The argmax function finds the maximum value among a list of values. It returns the index of the maximum.


let input = tf.tensor([1, 2, 1, 1]);

let test = tf.argMax(input);
				
Try it!

The argmax function takes a second parameter indicating whether to find the maximum along each row or each column. The default value is 0, which will maximize across columns. When set to 1, it will maximize across rows.


let input = tf.tensor([[1, 2, 10, 1],[1,2,3,4]]);
let test = tf.argMax(input,1);
				
Try it!

Matrix Operations


Linear Algebra

Contents