0
0
TensorFlowml~12 mins

Feature extraction approach in TensorFlow - Model Pipeline Trace

Choose your learning style9 modes available
Model Pipeline - Feature extraction approach

This pipeline shows how we use a pre-trained model to extract important features from images. These features help a smaller model learn faster and better for a new task.

Data Flow - 5 Stages
1Input images
1000 rows x 224 x 224 x 3Raw images loaded for processing1000 rows x 224 x 224 x 3
Image of a cat with 224x224 pixels and 3 color channels
2Preprocessing
1000 rows x 224 x 224 x 3Normalize pixel values to range 0-11000 rows x 224 x 224 x 3
Pixel value 120 becomes 0.47
3Feature extraction
1000 rows x 224 x 224 x 3Pass images through pre-trained CNN (e.g., MobileNetV2) without top layers1000 rows x 7 x 7 x 1280
Image features represented as 7x7 grid with 1280 channels
4Global average pooling
1000 rows x 7 x 7 x 1280Convert feature maps to 1D feature vector per image1000 rows x 1280
Feature vector like [0.12, 0.05, ..., 0.33]
5Classifier training
1000 rows x 1280Train a small dense layer to classify images using extracted features1000 rows x 10
Output probabilities for 10 classes like [0.1, 0.05, ..., 0.2]
Training Trace - Epoch by Epoch
Loss
2.0 |****
1.5 |*** 
1.0 |**  
0.5 |*   
0.0 +----
      1 2 3 4 5 Epochs
EpochLoss ↓Accuracy ↑Observation
11.850.45Model starts learning with moderate loss and accuracy
21.200.65Loss decreases and accuracy improves as model learns features
30.850.75Training continues with better performance
40.650.82Model converges with lower loss and higher accuracy
50.500.87Final epoch shows good accuracy and stable loss
Prediction Trace - 4 Layers
Layer 1: Input image
Layer 2: Feature extractor (MobileNetV2)
Layer 3: Global average pooling
Layer 4: Dense classifier layer
Model Quiz - 3 Questions
Test your understanding
What is the shape of the data after feature extraction?
A1000 rows x 224 x 224 x 3
B1000 rows x 7 x 7 x 1280
C1000 rows x 1280
D1000 rows x 10
Key Insight
Using a pre-trained model to extract features helps the new model learn faster and better by focusing on important image details instead of raw pixels.