tensor flow

Overview


2d Tensors


To create a 2d tensor with prescribed values. This example, creates a 2x2 matrix with the 4 values prescribed


const tensor = tf.tensor2d([1, 2, 3, 4], [2,2]);

//if not created within tidy, must dipose of tensor
tensor.dispose();
				
Try it!

Alternative way to create a 2d tensor with prescribed values. This example, creates a 2x2 matrix with the 4 values prescribed


const tensor = tf.tensor([[1, 2], [3,4]]);

//if not created within tidy, must dipose of tensor
tensor.dispose();
				
Try it!