AI Logic

Glossary

Input Tensor

Updated:

A diagram of input tensor shapes. On the left, examples of the number of dimensions are drawn as grids of cells, from top to bottom: a scalar (0-D), a vector (1-D), a matrix (2-D), and a higher-dimensional array (3-D or more) with layers stacked in depth. On the right, two columns flow from bottom to top. In the left column, images are turned into height × width grids stacked by the number of channels, and batch-size images are lined up to form a tensor of shape (batch size, height, width, channels), which is passed to a model such as a CNN. In the right column, sentences are turned into vectors by word embedding, forming a tensor of shape (batch size, max sentence length, embedding dimension), which is passed to a model such as an RNN or Transformer.

Description

An input tensor is the form in which data is fed to a deep learning model: a multidimensional array. Each dimension (axis) represents a different aspect of the data; for an image, for example, the axes typically represent width, height, and color channels. Tensors take the form of scalars (0-D), vectors (1-D), matrices (2-D), and higher-dimensional arrays (3-D or more), and they are regarded as the fundamental data structure that most deep learning frameworks cannot do without. For image data, an input tensor usually has the shape (batch size, height, width, channels), while text data in natural language processing is represented with word embeddings in the shape (batch size, max sentence length, embedding dimension). In this way, the input tensor is the basic unit for handling many kinds of data efficiently and serves as the foundation for a wide range of operations and transformations.

Use cases

Input tensors are used across a wide variety of deep learning models and tasks. Typical examples include the following: 1. In image processing (e.g., CNN), image data is passed to the model as an input tensor for filtering and feature extraction. 2. In natural language processing (e.g., RNN, Transformer), text is split into tokens, embedding vectors are generated, and the result is processed as an input tensor. 3. In audio processing (e.g., LSTM, CNN), audio waveforms or mel spectrograms are used as input tensors and applied to speech recognition tasks. 4. In reinforcement learning, a tensor representing the state of the environment is passed to the agent as input to decide its action. 5. In time-series analysis, data ordered in time is passed to the model as an input tensor for forecasting and anomaly detection. The input tensor is a key element that underpins how deep learning models understand and process data.

FAQ

Q. What is an input tensor?
A.

It is the numerical representation of the data passed to a deep learning model, structured as an array with multiple dimensions.

Q. What do the dimensions of a tensor mean?
A.

Each axis represents part of the data's structure. For example, for images the axes are height, width, and channels; for text, they are sentence length, embedding dimension, and so on.

Q. Where is it used?
A.

It is used in almost every deep learning task, including image recognition, natural language processing, speech recognition, reinforcement learning, and time-series analysis.