官术网_书友最值得收藏!

Tensors

Tensors are the basic components in TensorFlow. A tensor is a multidimensional collection of data elements. It is generally identified by shape, type, and rank. Rank refers to the number of dimensions of a tensor, while shape refers to the size of each dimension. You may have seen several examples of tensors before, such as in a zero-dimensional collection (also known as a scalar), a one-dimensional collection (also known as a vector), and a two-dimensional collection (also known as a matrix).

A scalar value is a tensor of rank 0 and shape []. A vector, or a one-dimensional array, is a tensor of rank 1 and shape [number_of_columns] or [number_of_rows]. A matrix, or a two-dimensional array, is a tensor of rank 2 and shape [number_of_rows, number_of_columns]. A three-dimensional array is a tensor of rank 3. In the same way, an n-dimensional array is a tensor of rank n.

A tensor can store data of one type in all of its dimensions, and the data type of a tensor is the same as the data type of its elements.

The data types that can be found in the TensorFlow library are described at the following link:  https://www.tensorflow.org/api_docs/python/tf/DType.

The following are the most commonly used data types in TensorFlow:

Use TensorFlow data types for defining tensors i nstead of native data types from Python or data types from NumPy.

Tensors can be created in the following ways:

  • By defining constants, operations, and variables, and passing the values to their constructor
  • By defining placeholders and passing the values to session.run()
  • By converting Python objects, such as scalar values, lists, NumPy arrays, and pandas DataFrames, with the tf.convert_to_tensor() function

Let's explore different ways of creating Tensors.

主站蜘蛛池模板: 调兵山市| 广昌县| 千阳县| 万年县| 吴桥县| 山西省| 温泉县| 杭锦旗| 尚义县| 定边县| 谷城县| 修武县| 胶南市| 林西县| 电白县| 南靖县| 石林| 建阳市| 镇坪县| 土默特左旗| 垫江县| 建始县| 北京市| 波密县| 馆陶县| 长治县| 大邑县| 德州市| 伊通| 福安市| 那坡县| 龙海市| 那坡县| 通城县| 信宜市| 罗田县| 兴山县| 道孚县| 崇信县| 平罗县| 得荣县|