Lesson 21-22 : Deep Learning with TensorFlow & PyTorch
Introduction
Most deep-learning tutorials stop at isolated notebooks: TensorFlow tensors in one file, a Keras Sequential in another, PyTorch nn.Module elsewhere, and a CIFAR-10 pipeline that never shares code with the tabular demos. That is useful for learning syntax, but it is not a system engineers can operate: there is no stable API surface, no durable experiment metadata, no clear boundary between reusable training logic and HTTP orchestration, and no way to run long jobs without blocking the request thread.
week_21_22_aiml_integrated_project is a self-contained capstone that consolidates TensorFlow/Keras and PyTorch fundamentals into one production-style application:
An installable Python package (
week2122_python) holding tensor demos, autodiff checks, Keras Iris and MNIST trainers, PyTorch tabular nets, CIFAR-10tf.datapipelines, a write-gate freeze store, and a vision engine composition layerA FastAPI backend exposing two API surfaces: a learning path for bounded topic demos and a product path for experiments, framework comparison, and async training
VisionML Platform β a React dashboard with a guided pipeline workflow, curriculum studio, and operations monitor with live metrics polling
Postgres-backed experiment metadata (async SQLAlchemy + Alembic), Docker volumes for artifacts and dataset caches; SQLite for local development
The engineering payoff is traceability: learning demos stay stateless and bounded; product workflows produce Run rows with metrics_json, Keras artifact paths, and status transitions you can query without opening log files. TensorFlow and PyTorch share one vision engineβframework comparison and CIFAR training call the same core modules whether invoked from curl or the dashboard.
Core Components
The stack is layered. Each topic below is a distinct building block; together they form one coherent vision workbench.
TensorFlow tensor and autodiff fundamentals
explore_tensors_demo in core/tensorflow/tensors.py constructs scalar, vector, matrix, and image-batch tensors, reports rank, shape, and dtype, and demonstrates tf.linalg.matmul. autodiff_demo in core/tensorflow/autodiff.py runs a GradientTape parity check. These power stateless learning endpoints that return tensor metadata directlyβno experiment registry involved.
Keras Sequential and Iris classification
core/tensorflow/iris_sequential.py builds a three-layer Sequential classifier on a shared Iris split from core/data/sklearn_tabular.py. iris_architecture_summary returns layer names, units, activations, and parameter count; train_iris compiles with Adam and sparse categorical crossentropy, returning validation accuracy and loss. The product vision engine re-exports train_iris as keras_train_iris for framework comparison.
Keras MNIST training with callbacks
core/tensorflow/mnist_baseline.py provides a quick MNIST smoke train for tensor/Keras introspection. core/tensorflow/mnist_training.py implements fuller training with callback metadata (get_callbacks_metadata) and train_mnist for bounded epoch runs. The vision engine exposes mnist_tf_forward_smoke and mnist_tf_train_product for product-side smoke tests.
PyTorch tensors, autograd, and simple classifiers
core/pytorch/tensors.py demonstrates tensor creation and shape operations. autograd_demo.py validates scalar and vector gradients against analytical expectations. simple_classifier.py runs a forward pass through a small nn.Module on synthetic batches. These modules stay framework-pureβno FastAPI imports.
Write-gate freeze store
WriteGateStore in core/runtime/write_gate.py is an in-memory key-value store with freeze / unfreeze write locking. A module-level demo store backs learning endpoints for set, get, freeze, unfreeze, status, and dump operationsβillustrating operational freeze patterns without touching Postgres.
PyTorch tabular neural networks
Keep going with the full lesson
The rest of this lesson β plus its implementation guide, runnable scripts and source code β is included with the course or an All Access plan. Create a free account to start the free lessons in every course.
Already a member? Sign in