当前位置:网站首页>What is the tensor in tensorflow?

What is the tensor in tensorflow?

2020-11-06 20:53:47 Alili, front end big bang

Tensor( tensor )

“ tensor ” The word was originally used by William · Ron · Hamilton is in 1846 In introducing . Yes , It's the Hamilton who invented quaternion :

 chart  3

  • Tensor It's actually a multidimensional array (multidimensional array)

  • Tensor The goal is to be able to create a higher dimensional matrix 、 vector .

 chart  1

An example of color

Color image file (RGB) It's usually handled as 3-d tensor, Every 2d array Medium element Represents a pixel ,R representative Red,G representative Green,B representative Blue

 chart  2

Multidimensional arrays

 chart  4

Draw a cube in three dimensions :

 chart  5

Higher dimensional tensors :

 chart  6

Initialize a vector

0 dimension

tf.tensor(1).print();

1 dimension

tf.tensor([1, 2, 3, 4]).print();
// or
tf.tensor1d([1, 2, 3]).print();

2 dimension

tf.tensor([[1, 2], [3, 4]]).print();
// or
tf.tensor2d([[1, 2], [3, 4]]).print();

3 dimension

tf.tensor([[[1], [2]], [[3], [4]]]).print();
// or
tf.tensor3d([[[1], [2]], [[3], [4]]]).print();

4 dimension

tf.tensor([[[[1], [2]], [[3], [4]]]]).print();
// or
tf.tensor4d([[[[1], [2]], [[3], [4]]]]).print();

5 dimension

tf.tensor([[[[[1], [2]], [[3], [4]]]]]).print();
// or
tf.tensor5d([[[[[1], [2]], [[3], [4]]]]]).print();

6 dimension

tf.tensor([[[[[[1],[2]],[[3],[4]]],[[[5],[6]],[[7],[8]]]]]]).print();
// or
tf.tensor6d([[[[[[1],[2]],[[3],[4]]],[[[5],[6]],[[7],[8]]]]]]).print();

For more articles, please follow my blog Alili The big bang at the front end Subscription number : Alili The big bang at the front end

版权声明
本文为[Alili, front end big bang]所创,转载请带上原文链接,感谢