Understanding of tensor in TensorFlow _tensorflow

Source: Internet
Author: User
Tags scalar python list

Oneself through the online inquiry about tensor explanation, a little finishing.


TensorFlow uses this data structure to represent all of the information. You can think of a tensor as an n-dimensional array or list. A tensor has a static type and a dynamic type of dimension. Tensor can flow between nodes in the diagram. Order

In the TensorFlow system, The dimensions of the tensor are described as orders. But the order of the tensor and the order of the matrices are not the same concept. The Order of the tensor (sometimes about, for example, order or degree or n-dimensional) is a quantity description of the number of Zhang Xiwei. For example, the following tensor (defined in Python list) is a 2-order.

    t = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

You can think of a second-order tensor, which is what we normally call a matrix, the first order tensor can be thought of as a vector. For a second order tensor you can use the statement t[i, J] to access any of these elements. And for the third-order tensor you can use ' T[i, J, K ' to access any of these elements. Order Math Example Python example 0 scalar (only size) s = 483 1 vectors (size and direction) v = [1.1, 2.2, 3.3] 2 matrix (data table) m = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] 3 3 order Sheets Quantity (data stereo) T = [[2], [4], [6]], [[8], [ten], [a]], [[[], [], []]] n n order (think for yourself) ....

Tensor is the core component of all depth learning frameworks, because all subsequent operations and optimization algorithms are based on tensor. The tensor defined in geometric algebra is based on the generalization of vectors and matrices, so we can think of scalar as 0 order tensor and vector as a first order tensor, then the matrix is the second order tensor.

For example, we can represent any RGB color picture as a third-order tensor (three dimensions are the height, width, and color data of the picture, respectively). As shown in the following picture is a common fruit picture, according to RGB three primary colors, it can be divided into three red, green and blue gray picture, if this method of expression in the form of tensor written out, is the bottom of the chart that table.

The figure shows only the first 5 rows, 320 columns of data, each square represents a pixel, where the data [1.0, 1.0, 1.0] is the color. Assuming that [1.0, 0, 0] is red, [0, 1.0, 0] is green, [0, 0, 1.0] is blue, then as the figure shows, the first 5 rows of data are all white.

By extending this definition, we can also use a four-order tensor to represent a dataset with more than one picture, with four dimensions: the number of the picture in the dataset, the height of the picture, the width, and the color data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.