Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Tensor Properties | Tensors
course content

Contenido del Curso

Introduction to TensorFlow

Tensor PropertiesTensor Properties

Tensor Properties

Tensors come with distinct properties that dictate their structure and how they process and store data.

  • Rank: It tells you the number of dimensions present in the tensor. For instance, a matrix has a rank of 2. You can get the rank of the tensor using the .ndim attribute:

Note

We've structured the definition of Python lists over multiple lines for clearer readability. You can condense it into a single line to see that it functions the same way.

  • Shape: This describes how many values exist in each dimension. A 2x3 matrix has a shape of (2, 3). The length of the shape parameter matches the tensor's rank (its number of dimensions). You can get the the shape of the tensor by the .shape attribute:

Note

Getting tensor shapes and ranks correct is crucial in deep learning. Dimension mismatches are common pitfalls, especially when building complex models in TensorFlow.

  • Types: Tensors come in various data types. While there are many, some common ones include float32, int32, and string. We'll delve deeper into tensor data types in upcoming chapters. You can get the the data type of the tensor by the .dtype attribute:

Note

Data type of a tensor is determined by the content it contains. It's essential that all elements within the tensor are of the same type.

  • Axes: Axes help us navigate through dimensions of tensors. By specifying an axis, you can pinpoint a specific layer or direction in the tensor, making it easier to process and understand the data. Axes correspond directly to shape dimensions. Each axis corresponds to a specific shape value, with the 0th axis aligning with the first shape value, the 1st axis with the second, and so on.

Tarea

In this task, you are provided with two tensors. The first tensor is already created for you; your task is to display its properties using the relevant tensor attributes. For the second tensor, you'll need to construct it yourself with the following specifications:

  • Rank: 3.
  • Shape: (2, 4, 3).
  • Data type: float.

So, your steps are:

  1. Retrieve the properties of the first tensor.
  2. Construct a tensor that meets the specified criteria.

¿Todo estuvo claro?

Sección 1. Capítulo 3
toggle bottom row
course content

Contenido del Curso

Introduction to TensorFlow

Tensor PropertiesTensor Properties

Tensor Properties

Tensors come with distinct properties that dictate their structure and how they process and store data.

  • Rank: It tells you the number of dimensions present in the tensor. For instance, a matrix has a rank of 2. You can get the rank of the tensor using the .ndim attribute:

Note

We've structured the definition of Python lists over multiple lines for clearer readability. You can condense it into a single line to see that it functions the same way.

  • Shape: This describes how many values exist in each dimension. A 2x3 matrix has a shape of (2, 3). The length of the shape parameter matches the tensor's rank (its number of dimensions). You can get the the shape of the tensor by the .shape attribute:

Note

Getting tensor shapes and ranks correct is crucial in deep learning. Dimension mismatches are common pitfalls, especially when building complex models in TensorFlow.

  • Types: Tensors come in various data types. While there are many, some common ones include float32, int32, and string. We'll delve deeper into tensor data types in upcoming chapters. You can get the the data type of the tensor by the .dtype attribute:

Note

Data type of a tensor is determined by the content it contains. It's essential that all elements within the tensor are of the same type.

  • Axes: Axes help us navigate through dimensions of tensors. By specifying an axis, you can pinpoint a specific layer or direction in the tensor, making it easier to process and understand the data. Axes correspond directly to shape dimensions. Each axis corresponds to a specific shape value, with the 0th axis aligning with the first shape value, the 1st axis with the second, and so on.

Tarea

In this task, you are provided with two tensors. The first tensor is already created for you; your task is to display its properties using the relevant tensor attributes. For the second tensor, you'll need to construct it yourself with the following specifications:

  • Rank: 3.
  • Shape: (2, 4, 3).
  • Data type: float.

So, your steps are:

  1. Retrieve the properties of the first tensor.
  2. Construct a tensor that meets the specified criteria.

¿Todo estuvo claro?

Sección 1. Capítulo 3
toggle bottom row
some-alt