$ show ageron/handson-ml2
This repository is the companion code for the second edition of AurΓ©lien GΓ©ron's 'Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow'. It consists of 19 Jupyter notebooks that teach a wide range of machine learning and deep learning topics, including classification, regression, neural networks, CNNs, RNNs, NLP, reinforcement learning, and scalable deployment. The code is well-structured and annotated, designed for interactive learning. While not a production application, the notebooks contain several high-quality, reusable components such as custom Keras layers, training loops, and learning rate schedulers. The repository also includes Docker configurations and environment files to ensure reproducibility. However, the second edition is explicitly outdated, with libraries pinned to versions from 2021 (TensorFlow 2.6, Scikit-Learn 1.0), and the README directs users to the third edition and a PyTorch version. The data sources are standard benchmark datasets bundled as static files or downloaded from URLs that may change.
The LLM identified 5 files worth highlighting for reuse:
Contains custom Keras callbacks `ExponentialLearningRate` and `OneCycleScheduler` that implement the learning rate range test and 1Cycle scheduling policy. These are self-contained, well-documented patterns for systematic hyperparameter tuning, easily extractable for any TensorFlow/Keras training pipeline.
Demonstrates custom Keras layer creation (e.g., `AddGaussianNoise`, `LayerNormalization`, `ResidualBlock`), custom training loops with `tf.GradientTape`, and custom optimizers. These patterns are foundational for extending TensorFlow and are reusable across projects requiring non-standard architectures or training procedures.
Implements a `PositionalEncoding` layer and a `MultiHeadAttention` layer from scratch, forming the core building blocks of Transformer models. These are clean, educational implementations that can be extracted and used for toy NLP tasks or as reference for production-level attention mechanisms.
A Dockerfile for creating a reproducible Jupyter environment with all dependencies pre-installed. It is parameterized via environment variables and includes useful scripts for notebook checkpoint management. This infrastructure component can be reused by anyone wanting to set up a consistent ML development environment.
A Conda environment specification that pins all Python packages (including TensorFlow, Scikit-Learn, Jupyter) to specific versions. It serves as a template for creating stable, reproducible environments for ML projects, ensuring that code behaves consistently across machines.