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.data pipelines, 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

LabTopicKey Concepts
lab-01-keras-functional-apiKeras Functional APImulti-input, shared layers, custom layers
lab-02-tf-data-pipelinetf.data Input Pipelines.map(), .batch(), .prefetch(), augmentation
lab-03-tflite-edge-deployTFLite Conversion & QuantizationINT8 post-training quantization, benchmarking

TF vs PyTorch Cheatsheet

ConceptPyTorchTensorFlow/Keras
Model definitionnn.Moduletf.keras.Model or Functional API
Forward passmodel(x)model(x) or model.predict(x)
Training loopmanualmodel.fit() or manual
Lossnn.CrossEntropyLosstf.keras.losses.SparseCategoricalCrossentropy
Optimizertorch.optim.Adamtf.keras.optimizers.Adam
Datasettorch.utils.data.Datasettf.data.Dataset
Exporttorch.onnx.export / TorchScriptmodel.save() (SavedModel) / TFLite
Gradient tapeloss.backward()tf.GradientTape