0
0
TensorFlowml~12 mins

Why tensors are the fundamental data unit in TensorFlow - Model Pipeline Impact

Choose your learning style9 modes available
Model Pipeline - Why tensors are the fundamental data unit

This pipeline shows how tensors, which are multi-dimensional arrays, are used as the basic data units in machine learning. Tensors flow through data preparation, model training, and prediction steps, enabling efficient computation and learning.

Data Flow - 6 Stages
1Raw Data Input
1000 rows x 5 columnsConvert raw data into tensors1000 rows x 5 columns tensor
[[5.1, 3.5, 1.4, 0.2, 0], [4.9, 3.0, 1.4, 0.2, 0], ...]
2Normalization
1000 rows x 5 columns tensorScale features to range 0-11000 rows x 5 columns tensor
[[0.52, 0.75, 0.14, 0.1, 0], [0.48, 0.64, 0.14, 0.1, 0], ...]
3Train/Test Split
1000 rows x 5 columns tensorSplit data into training and testing setsTraining: 800 rows x 5 columns tensor, Testing: 200 rows x 5 columns tensor
Training sample: [[0.52, 0.75, 0.14, 0.1, 0], ...], Testing sample: [[0.48, 0.64, 0.14, 0.1, 0], ...]
4Model Input Layer
800 rows x 5 columns tensorFeed tensors into neural network800 rows x 5 columns tensor
[[0.52, 0.75, 0.14, 0.1, 0], ...]
5Hidden Layer (Dense)
800 rows x 5 columns tensorMultiply by weights and add bias, apply ReLU activation800 rows x 10 columns tensor
[[0.0, 1.2, 0.5, ..., 0.3], ...]
6Output Layer (Softmax)
800 rows x 10 columns tensorCalculate class probabilities800 rows x 3 columns tensor
[[0.7, 0.2, 0.1], [0.1, 0.8, 0.1], ...]
Training Trace - Epoch by Epoch
Loss
1.2 |*****
0.9 |****
0.7 |***
0.5 |**
0.4 |*
EpochLoss ↓Accuracy ↑Observation
11.20.45Model starts learning, loss is high, accuracy low
20.90.60Loss decreases, accuracy improves
30.70.72Model continues to learn, better predictions
40.50.80Loss drops further, accuracy rises
50.40.85Model converges with good accuracy
Prediction Trace - 3 Layers
Layer 1: Input Tensor
Layer 2: Hidden Layer (Dense + ReLU)
Layer 3: Output Layer (Softmax)
Model Quiz - 3 Questions
Test your understanding
Why are tensors used as the fundamental data unit in this pipeline?
ABecause tensors can represent multi-dimensional data efficiently
BBecause tensors are only one-dimensional arrays
CBecause tensors cannot be used in neural networks
DBecause tensors are slow to compute
Key Insight
Tensors are essential because they hold data in multi-dimensional arrays that flow through each step of machine learning. They allow efficient math operations and keep data organized for the model to learn patterns and make predictions.