Starting with Machine Learning on devices like MCU - Part 5 (Tensors)

Starting with Machine Learning on devices like MCU - Part 5 (Tensors)

Machine learning (ML) models generate and work with tensors. So, what is a tensor?

A tensor is a multi-dimensional array. Let us see the difference between Scalar, Vector, Matrix, Tensor.

Scalar: 0D (e.g., 5)
Vector: 1D (e.g., [1, 2, 3])
Matrix: 2D (e.g., [[1, 2], [3, 4]])
Tensor: 3D or higher (e.g., an image batch [batch, height, width, channels])

In frameworks like TensorFlow, PyTorch, or ONNX, tensors are the core data structure for both:

Inputs (e.g., image pixels, sensor readings, etc.)
Outputs (e.g., class probabilities, coordinates, predictions)

Step Description Example Tensor
Input Data fed into the model [batch_size, features]
Intermediate Hidden layer activations [batch_size, hidden_units]
Output Model predictions [batch_size, classes]

Post a Comment

0 Comments