Phase 04: TensorFlow / Keras
Weeks 9-10 | 3 Labs
TensorFlow/Keras is the dominant production framework at scale — used by Google, Waymo, DeepMind, and most cloud ML services. Master the Keras Functional API,
tf.datapipelines, and TFLite deployment.
Why TensorFlow?
- TFLite / TF.js / Edge TPU: deployment to mobile and edge devices
- tf.data: high-performance input pipelines with prefetch/cache/map
- SavedModel format: the standard for serving with TF Serving
- Keras Functional API: build complex DAG models (multi-input, multi-output)
- TF Hub: pretrained models with fine-tuning in 10 lines of code
Lab Structure
| Lab | Topic | Key Concepts |
|---|---|---|
| lab-01-keras-functional-api | Keras Functional API | multi-input, shared layers, custom layers |
| lab-02-tf-data-pipeline | tf.data Input Pipelines | .map(), .batch(), .prefetch(), augmentation |
| lab-03-tflite-edge-deploy | TFLite Conversion & Quantization | INT8 post-training quantization, benchmarking |
TF vs PyTorch Cheatsheet
| Concept | PyTorch | TensorFlow/Keras |
|---|---|---|
| Model definition | nn.Module | tf.keras.Model or Functional API |
| Forward pass | model(x) | model(x) or model.predict(x) |
| Training loop | manual | model.fit() or manual |
| Loss | nn.CrossEntropyLoss | tf.keras.losses.SparseCategoricalCrossentropy |
| Optimizer | torch.optim.Adam | tf.keras.optimizers.Adam |
| Dataset | torch.utils.data.Dataset | tf.data.Dataset |
| Export | torch.onnx.export / TorchScript | model.save() (SavedModel) / TFLite |
| Gradient tape | loss.backward() | tf.GradientTape |