Transfer Learning for CIFAR-10: A Feature-Extraction Approach Using EfficientNetB0
1. Introduction
Image classification is one of the foundational tasks in computer vision. The CIFAR-10 dataset consists of 60,000 colour images (50,000 train / 10,000 test), each 32×32 pixels, distributed evenly across ten categories: airplane, automobile, bird, cat, deer, dog, frog, horse, ship, and truck.
Training a deep CNN from random weights is feasible but slow — typically demanding hundreds of epochs, careful learning-rate scheduling, and aggressive regularisation. An alternative, widely used in industry, is transfer learning: borrowing feature representations learned by a large model on a bigger dataset and adapting them to the target task.
cifar10.h5 · Expose a preprocess_data(X, Y) function · Guard training code with if __name__ == '__main__'
2. Materials and Methods
2.1 Dataset
CIFAR-10 was loaded via tensorflow.keras.datasets.cifar10, already partitioned into 50,000 training and 10,000 test images. No augmentation was applied in the baseline run, because cached features rule it out during head training. No separate hold-out split is described. If the 10,000 test images also drove early stopping and learning-rate reduction, the reported validation accuracy is somewhat optimistic as an estimate of performance on unseen data.
2.2 Pre-processing
The preprocess_data function casts pixel arrays to float32, calls EfficientNetB0's preprocess_input, and one-hot-encodes labels using to_categorical with num_classes=10. In Keras, EfficientNet's preprocess_input is a pass-through, because the model contains its own rescaling and normalization layers and expects inputs in [0, 255]. Pixels should therefore not be scaled beforehand.
2.3 Model Architecture
The architecture is a three-block sequential pipeline. The frozen EfficientNetB0 backbone acts purely as a feature extractor, with a lightweight trainable head attached on top.
tf.image.resize → (224, 224)2.4 The Resolution Mismatch Problem
EfficientNetB0 was designed for 224×224 inputs; CIFAR-10 images are only 32×32. The backbone downsamples by a factor of 32, so a 32×32 input would leave a 1×1 final feature map with very little spatial detail. A Lambda layer bilinearly rescales every batch to 224×224 on the fly using tf.image.resize. This avoids a separate pre-processing pass, though running the backbone at 224×224 is the main compute cost of the pipeline.
2.5 Feature Pre-computation Strategy
Freeze the backbone and call it with training=False when extracting features, so BatchNorm uses stored statistics and stochastic training layers are inactive. Determinism also depends on preprocessing and runtime kernels. Caching fixed features avoids repeating backbone inference each epoch; image augmentation must occur before extraction or require new cached features.
Benefits of Caching
- Head training reduced from hours to minutes (author-reported)
- Hyperparameter iteration becomes practical
- No backbone recomputation per epoch
Trade-offs
- About 310 MB of RAM for the float32 features: (50,000 + 10,000) × 1,280 × 4 bytes
- Augmentation cannot be applied at this stage
- Requires separate partial-model forward pass
2.6 Training Setup
The classifier head was compiled with Adam (lr = 1×10⁻³), categorical cross-entropy loss, and two callbacks:
If end-to-end validation accuracy fell below 87%, a fine-tuning fallback was designed to unfreeze the top 20 EfficientNetB0 layers and continue at lr = 5×10⁻⁵. In practice, this fallback was never triggered.
The cloud is illustrative — real EfficientNetB0 embeddings are 1280-dimensional and cannot be drawn, so this is a stand-in that runs from unstructured noise to well-separated clusters. The accuracy is computed on these synthetic points, not on CIFAR-10. A nearest-centroid linear probe is fitted on 60% of the points and scored on the held-out 40%, recomputed every time you move the slider. Drag Features to the left and the probe collapses to chance: with no class structure in the representation, no linear head can recover it. Drag it right and the same probe becomes near-perfect without a single layer of the backbone changing. That is the whole argument for freezing — if the representation already separates the classes, the only thing left to fit is a head of 12,810 parameters for a hypothetical 1280→10 linear head, roughly 0.3% of the backbone-plus-linear-head model; the reported 512→256→10 head above instead has 791,306 trainable parameters plus 1,536 non-trainable BatchNorm statistics.
Analytic illustration, not recorded training data. If the chart cannot load, the author-reported table below remains available.
| Metric | Head-only Training | Full Model (end-to-end) |
|---|---|---|
| Epochs to convergence | ~18 | N/A (backbone frozen) |
| Final training accuracy | ~93% | — |
| Validation accuracy | ~88% | ~88% |
| Training time (V100 GPU) | < 3 min | < 1 min (eval only) |
3.2 Final Validation Accuracy
The author reports that the assembled end-to-end model achieved: 87–89% validation accuracy meeting the project's ≥87% requirement. The fine-tuning fallback was not needed in the author's runs, so frozen EfficientNetB0 features were sufficient for that target. Well-tuned CIFAR-10 models trained end to end reach substantially higher accuracy, so this target should not be read as a performance ceiling.
3.3 Per-Class Observations
The author observed the best performance on structurally distinctive classes such as ships, airplanes, and automobiles, and the weakest on visually similar pairs like cat vs. dog and deer vs. horse. This is qualitative: per-class figures are not published here.
4. Discussion
4.1 Why EfficientNetB0?
The author reports evaluating several Keras Applications (VGG16, ResNet50, MobileNetV2). EfficientNetB0 was selected for three reasons: a compact parameter count (about 5.3M with its ImageNet classifier, about 4.05M without it), competitive ImageNet accuracy, and a compound-scaling design that balances width, depth, and resolution.
4.2 Limitations
Resolution Upscaling
- Bilinear interpolation from 32×32 to 224×224 introduces artificial blurring
- Network operates outside its natural domain
- Future work: patch-based methods or custom low-resolution backbones
No Data Augmentation
- Cached features are fixed — augmentation can't be applied post-extraction
- Augmentation before extraction requires multiple forward passes and extra memory
- Trade-off deemed acceptable given accuracy achieved
4.3 Reproducibility
No executable training pipeline, environment lockfile, run logs, saved model, split indices or confusion matrix is supplied here. Seed settings and hardware in the narrative are author-reported and cannot establish reproducibility. The browser charts are not training artifacts.
4.4 Future Directions
Three avenues could push accuracy higher. First, selective fine-tuning of upper EfficientNetB0 blocks would let features adapt to CIFAR-10, though the gain would need to be measured. Second, a different head could extract more from the 1,280-dimensional features. Third, augmenting images before the backbone during fine-tuning would restore the regularization that caching gives up.
5. Key Hyperparameters
| Hyperparameter | Value |
|---|---|
| Backbone | EfficientNetB0 (ImageNet weights) |
| Upscaling target | 224 × 224 px |
| Feature dimension | 1,280 |
| Head Dense layers | 512 → 256 → 10 |
| Dropout rates | 0.4, 0.3 |
| Optimiser | Adam |
| Initial learning rate | 1×10⁻³ |
| Batch size (feature extraction) | 256 |
| Max epochs | 60 (EarlyStopping patience = 8) |
| Min LR (ReduceLROnPlateau) | 1×10⁻⁶ |
| Fine-tune LR (if triggered) | 5×10⁻⁵ |
| Fine-tune layers unfrozen | Top 20 of EfficientNetB0 (non-BN) |
Conclusion
This project shows that a frozen EfficientNetB0 backbone can be a computationally efficient route to its target accuracy on CIFAR-10. The author reports that pre-computing and caching feature vectors reduced head training from hours to minutes, with 87-89% validation accuracy.
The resolution mismatch between CIFAR-10's 32×32 images and EfficientNetB0's 224×224 native input is elegantly handled by a Lambda upsampling layer, requiring no offline pre-processing. The overall design prioritises speed and reproducibility without sacrificing accuracy.
Key takeaway: for small datasets with limited compute, a frozen pre-trained backbone with a lightweight head is often a good starting point. It is fast, but it trades away accuracy: this project's figures are below what well-tuned end-to-end training can achieve on CIFAR-10.
References
- Chollet, F. et al. (2015). Keras. https://keras.io
- Krizhevsky, A. (2009). Learning Multiple Layers of Features from Tiny Images. Technical Report, University of Toronto.
- Tan, M., & Le, Q. V. (2019). EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks. ICML 2019, 97, 6105–6114.
- Tan, M., & Le, Q. V. (2021). EfficientNetV2: Smaller Models and Faster Training. ICML 2021.
- Yosinski, J., Clune, J., Bengio, Y., & Lipson, H. (2014). How transferable are features in deep neural networks? NeurIPS 2014, 27.
- He, K., Zhang, X., Ren, S., & Sun, J. (2016). Deep Residual Learning for Image Recognition. CVPR 2016, 770–778.
- Abadi, M. et al. (2016). TensorFlow: A System for Large-Scale Machine Learning. OSDI 2016.