Code examples

Code examples

Our code examples are short (less than 300 lines of code), focused demonstrations of vertical deep learning workflows.

All of our examples are written as Jupyter notebooks and can be run in one click in Google Colab, a hosted notebook environment that requires no setup and runs in the cloud. Google Colab includes GPU and TPU runtimes.

Computer Vision

Image classification

StarterKeras VersionTitleDate CreatedLast Modified
V3Image classification from scratch2020/04/272023/11/09
V3Simple MNIST convnet2015/06/192020/04/21
V3Image classification via fine-tuning with EfficientNet2020/06/302023/07/10
V3Image classification with Vision Transformer2021/01/182021/01/18
V3Classification using Attention-based Deep Multiple Instance Learning (MIL).2021/08/162021/11/25
V3Image classification with modern MLP models2021/05/302023/08/03
V3MobileViT: A mobile-friendly Transformer-based model for image classification2021/10/202024/02/11
V3Pneumonia Classification on TPU2020/07/282024/02/12
V3Compact Convolutional Transformers2021/06/302023/08/07
V3Image classification with ConvMixer2021/10/122021/10/12
V3Image classification with EANet (External Attention Transformer)2021/10/192023/07/18
V3Involutional neural networks2021/07/252021/07/25
V3Image classification with Perceiver2021/04/302023/12/30
V3Few-Shot learning with Reptile2020/05/212023/07/20
V3Semi-supervised image classification using contrastive pretraining with SimCLR2021/04/242024/03/04
V3Image classification with Swin Transformers2021/09/082021/09/08
V2Train a Vision Transformer on small datasets2022/01/072022/01/10
V2A Vision Transformer without Attention2022/02/242022/10/15
V3Image Classification using Global Context Vision Transformer2023/10/302023/10/30
V3Image Classification using BigTransfer (BiT)2021/09/242024/01/03
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Semi-supervised image classification using contrastive pretraining with SimCLR2021/04/242024/03/04
V3Pneumonia Classification on TPU2020/07/282024/02/12
V3MobileViT: A mobile-friendly Transformer-based model for image classification2021/10/202024/02/11
V3Image Classification using BigTransfer (BiT)2021/09/242024/01/03
V3Image classification with Perceiver2021/04/302023/12/30
V3Image classification from scratch2020/04/272023/11/09
V3Image Classification using Global Context Vision Transformer2023/10/302023/10/30
V3Compact Convolutional Transformers2021/06/302023/08/07
V3Image classification with modern MLP models2021/05/302023/08/03
V3Few-Shot learning with Reptile2020/05/212023/07/20
V3Image classification with EANet (External Attention Transformer)2021/10/192023/07/18
V3Image classification via fine-tuning with EfficientNet2020/06/302023/07/10
V2A Vision Transformer without Attention2022/02/242022/10/15
V2Train a Vision Transformer on small datasets2022/01/072022/01/10
V3Classification using Attention-based Deep Multiple Instance Learning (MIL).2021/08/162021/11/25
V3Image classification with ConvMixer2021/10/122021/10/12
V3Image classification with Swin Transformers2021/09/082021/09/08
V3Involutional neural networks2021/07/252021/07/25
V3Image classification with Vision Transformer2021/01/182021/01/18
V3Simple MNIST convnet2015/06/192020/04/21

Image segmentation

StarterKeras VersionTitleDate CreatedLast Modified
V3Image segmentation with a U-Net-like architecture2019/03/202020/04/20
V3Multiclass semantic segmentation using DeepLabV3+2021/08/312024/01/05
V2Highly accurate boundaries segmentation using BASNet2023/05/302023/07/13
V3Image Segmentation using Composable Fully-Convolutional Networks2023/06/162023/12/25
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Multiclass semantic segmentation using DeepLabV3+2021/08/312024/01/05
V3Image Segmentation using Composable Fully-Convolutional Networks2023/06/162023/12/25
V2Highly accurate boundaries segmentation using BASNet2023/05/302023/07/13
V3Image segmentation with a U-Net-like architecture2019/03/202020/04/20

Object detection

StarterKeras VersionTitleDate CreatedLast Modified
V2Object Detection with RetinaNet2020/05/172023/07/10
V3Keypoint Detection with Transfer Learning2021/05/022023/07/19
V3Object detection with Vision Transformers2022/03/272023/11/20
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Object detection with Vision Transformers2022/03/272023/11/20
V3Keypoint Detection with Transfer Learning2021/05/022023/07/19
V2Object Detection with RetinaNet2020/05/172023/07/10

3D

StarterKeras VersionTitleDate CreatedLast Modified
V33D image classification from CT scans2020/09/232024/01/11
V3Monocular depth estimation2021/08/302024/08/13
V33D volumetric rendering with NeRF2021/08/092023/11/13
V3Point cloud segmentation with PointNet2020/10/232020/10/24
V3Point cloud classification with PointNet2020/05/252024/01/09
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Monocular depth estimation2021/08/302024/08/13
V33D image classification from CT scans2020/09/232024/01/11
V3Point cloud classification with PointNet2020/05/252024/01/09
V33D volumetric rendering with NeRF2021/08/092023/11/13
V3Point cloud segmentation with PointNet2020/10/232020/10/24

OCR

StarterKeras VersionTitleDate CreatedLast Modified
V3OCR model for reading Captchas2020/06/142024/03/13
V3Handwriting recognition2021/08/162024/09/01
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Handwriting recognition2021/08/162024/09/01
V3OCR model for reading Captchas2020/06/142024/03/13

Image enhancement

StarterKeras VersionTitleDate CreatedLast Modified
V3Convolutional autoencoder for image denoising2021/03/012021/03/01
V3Low-light image enhancement using MIRNet2021/09/112023/07/15
V3Image Super-Resolution using an Efficient Sub-Pixel CNN2020/07/282020/08/27
V3Enhanced Deep Residual Networks for single-image super-resolution2022/04/072024/08/27
V3Zero-DCE for low-light image enhancement2021/09/182023/07/15
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Enhanced Deep Residual Networks for single-image super-resolution2022/04/072024/08/27
V3Low-light image enhancement using MIRNet2021/09/112023/07/15
V3Zero-DCE for low-light image enhancement2021/09/182023/07/15
V3Convolutional autoencoder for image denoising2021/03/012021/03/01
V3Image Super-Resolution using an Efficient Sub-Pixel CNN2020/07/282020/08/27

Data augmentation

StarterKeras VersionTitleDate CreatedLast Modified
V3CutMix data augmentation for image classification2021/06/082023/11/14
V3MixUp augmentation for image classification2021/03/062023/07/24
V3RandAugment for Image Classification for Improved Robustness2021/03/132023/12/12
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3RandAugment for Image Classification for Improved Robustness2021/03/132023/12/12
V3CutMix data augmentation for image classification2021/06/082023/11/14
V3MixUp augmentation for image classification2021/03/062023/07/24

Image & Text

StarterKeras VersionTitleDate CreatedLast Modified
V3Image Captioning2021/05/292021/10/31
V2Natural language image search with a Dual Encoder2021/01/302021/01/30
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Image Captioning2021/05/292021/10/31
V2Natural language image search with a Dual Encoder2021/01/302021/01/30

Vision models interpretability

StarterKeras VersionTitleDate CreatedLast Modified
V3Visualizing what convnets learn2020/05/292020/05/29
V3Model interpretability with Integrated Gradients2020/06/022020/06/02
V3Investigating Vision Transformer representations2022/04/122023/11/20
V3Grad-CAM class activation visualization2020/04/262021/03/07
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Investigating Vision Transformer representations2022/04/122023/11/20
V3Grad-CAM class activation visualization2020/04/262021/03/07
V3Model interpretability with Integrated Gradients2020/06/022020/06/02
V3Visualizing what convnets learn2020/05/292020/05/29

Image similarity search

StarterKeras VersionTitleDate CreatedLast Modified
V2Near-duplicate image search2021/09/102023/08/30
V3Semantic Image Clustering2021/02/282021/02/28
V3Image similarity estimation using a Siamese Network with a contrastive loss2021/05/062022/09/10
V3Image similarity estimation using a Siamese Network with a triplet loss2021/03/252021/03/25
V3Metric learning for image similarity search2020/06/052020/06/09
V2Metric learning for image similarity search using TensorFlow Similarity2021/09/302022/02/29
V3Self-supervised contrastive learning with NNCLR2021/09/132024/01/22
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Self-supervised contrastive learning with NNCLR2021/09/132024/01/22
V2Near-duplicate image search2021/09/102023/08/30
V3Image similarity estimation using a Siamese Network with a contrastive loss2021/05/062022/09/10
V2Metric learning for image similarity search using TensorFlow Similarity2021/09/302022/02/29
V3Image similarity estimation using a Siamese Network with a triplet loss2021/03/252021/03/25
V3Semantic Image Clustering2021/02/282021/02/28
V3Metric learning for image similarity search2020/06/052020/06/09

Video

StarterKeras VersionTitleDate CreatedLast Modified
V3Video Classification with a CNN-RNN Architecture2021/05/282023/12/08
V3Next-Frame Video Prediction with Convolutional LSTMs2021/06/022023/11/10
V3Video Classification with Transformers2021/08/062023/07/22
V3Video Vision Transformer2022/01/122024/01/15
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Video Vision Transformer2022/01/122024/01/15
V3Video Classification with a CNN-RNN Architecture2021/05/282023/12/08
V3Next-Frame Video Prediction with Convolutional LSTMs2021/06/022023/11/10
V3Video Classification with Transformers2021/08/062023/07/22

Performance recipes

StarterKeras VersionTitleDate CreatedLast Modified
V3Gradient Centralization for Better Training Performance2021/06/182023/07/25
V3Learning to tokenize in Vision Transformers2021/12/102023/08/14
V3Knowledge Distillation2020/09/012020/09/01
V3FixRes: Fixing train-test resolution discrepancy2021/10/082021/10/10
V3Class Attention Image Transformers with LayerScale2022/09/192022/11/21
V3Augmenting convnets with aggregated attention2022/01/222022/01/22
V3Learning to Resize in Computer Vision2021/04/302023/12/18
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Learning to Resize in Computer Vision2021/04/302023/12/18
V3Learning to tokenize in Vision Transformers2021/12/102023/08/14
V3Gradient Centralization for Better Training Performance2021/06/182023/07/25
V3Class Attention Image Transformers with LayerScale2022/09/192022/11/21
V3Augmenting convnets with aggregated attention2022/01/222022/01/22
V3FixRes: Fixing train-test resolution discrepancy2021/10/082021/10/10
V3Knowledge Distillation2020/09/012020/09/01

Other

StarterKeras VersionTitleDate CreatedLast Modified
V2Semi-supervision and domain adaptation with AdaMatch2021/06/192021/06/19
V2Barlow Twins for Contrastive SSL2021/11/042021/12/20
V2Consistency training with supervision2021/04/132021/04/19
V2Distilling Vision Transformers2022/04/052022/04/08
V2Focal Modulation: A replacement for Self-Attention2023/01/252023/02/15
V2Using the Forward-Forward Algorithm for Image Classification2023/01/082024/09/17
V2Masked image modeling with Autoencoders2021/12/202021/12/21
V2Segment Anything Model with 🤗Transformers2023/07/112023/07/11
V2Semantic segmentation with SegFormer and Hugging Face Transformers2023/01/252023/01/29
V2Self-supervised contrastive learning with SimSiam2021/03/192023/12/29
V2Supervised Contrastive Learning2020/11/302020/11/30
V2When Recurrence meets Transformers2023/03/122024/11/12
V2Efficient Object Detection with YOLOV8 and KerasCV2023/06/262023/06/26
StarterKeras VersionTitleDate CreatedLast Modified ▼
V2When Recurrence meets Transformers2023/03/122024/11/12
V2Using the Forward-Forward Algorithm for Image Classification2023/01/082024/09/17
V2Self-supervised contrastive learning with SimSiam2021/03/192023/12/29
V2Segment Anything Model with 🤗Transformers2023/07/112023/07/11
V2Efficient Object Detection with YOLOV8 and KerasCV2023/06/262023/06/26
V2Focal Modulation: A replacement for Self-Attention2023/01/252023/02/15
V2Semantic segmentation with SegFormer and Hugging Face Transformers2023/01/252023/01/29
V2Distilling Vision Transformers2022/04/052022/04/08
V2Masked image modeling with Autoencoders2021/12/202021/12/21
V2Barlow Twins for Contrastive SSL2021/11/042021/12/20
V2Semi-supervision and domain adaptation with AdaMatch2021/06/192021/06/19
V2Consistency training with supervision2021/04/132021/04/19
V2Supervised Contrastive Learning2020/11/302020/11/30

Natural Language Processing

Text classification

StarterKeras VersionTitleDate CreatedLast Modified
V3Text classification from scratch2019/11/062020/05/17
V3Review Classification using Active Learning2021/10/292024/05/08
V3Text Classification using FNet (KerasHub)2022/06/012022/12/21
V2Large-scale multi-label text classification2020/09/252020/12/23
V3Text classification with Transformer2020/05/102024/01/18
V3Text classification with Switch Transformer2020/05/102021/02/15
V2Text classification using Decision Forests and pretrained embeddings2022/09/052022/09/05
V3Using pre-trained word embeddings2020/05/052020/05/05
V3Bidirectional LSTM on IMDB2020/05/032020/05/03
V3Data Parallel Training with KerasHub and tf.distribute2023/07/072023/07/07
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Review Classification using Active Learning2021/10/292024/05/08
V3Text classification with Transformer2020/05/102024/01/18
V3Data Parallel Training with KerasHub and tf.distribute2023/07/072023/07/07
V3Text Classification using FNet (KerasHub)2022/06/012022/12/21
V2Text classification using Decision Forests and pretrained embeddings2022/09/052022/09/05
V3Text classification with Switch Transformer2020/05/102021/02/15
V2Large-scale multi-label text classification2020/09/252020/12/23
V3Text classification from scratch2019/11/062020/05/17
V3Using pre-trained word embeddings2020/05/052020/05/05
V3Bidirectional LSTM on IMDB2020/05/032020/05/03

Machine translation

StarterKeras VersionTitleDate CreatedLast Modified
V3English-to-Spanish translation with KerasHub2022/05/262024/04/30
V3English-to-Spanish translation with a sequence-to-sequence Transformer2021/05/262023/02/25
V3Character-level recurrent sequence-to-sequence model2017/09/292023/11/22
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3English-to-Spanish translation with KerasHub2022/05/262024/04/30
V3Character-level recurrent sequence-to-sequence model2017/09/292023/11/22
V3English-to-Spanish translation with a sequence-to-sequence Transformer2021/05/262023/02/25

Entailment prediction

StarterKeras VersionTitleDate CreatedLast Modified
V2Multimodal entailment2021/08/082021/08/15
StarterKeras VersionTitleDate CreatedLast Modified ▼
V2Multimodal entailment2021/08/082021/08/15

Named entity recognition

StarterKeras VersionTitleDate CreatedLast Modified
V3Named Entity Recognition using Transformers2021/06/232024/04/05
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Named Entity Recognition using Transformers2021/06/232024/04/05

Sequence-to-sequence

StarterKeras VersionTitleDate CreatedLast Modified
V2Text Extraction with BERT2020/05/232020/05/23
V3Sequence to sequence learning for performing number addition2015/08/172024/02/13
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Sequence to sequence learning for performing number addition2015/08/172024/02/13
V2Text Extraction with BERT2020/05/232020/05/23

Text similarity search

StarterKeras VersionTitleDate CreatedLast Modified
V3Semantic Similarity with KerasHub2023/02/252023/02/25
V3Semantic Similarity with BERT2020/08/152020/08/29
V3Sentence embeddings using Siamese RoBERTa-networks2023/07/142023/07/14
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Sentence embeddings using Siamese RoBERTa-networks2023/07/142023/07/14
V3Semantic Similarity with KerasHub2023/02/252023/02/25
V3Semantic Similarity with BERT2020/08/152020/08/29

Language modeling

StarterKeras VersionTitleDate CreatedLast Modified
V3End-to-end Masked Language Modeling with BERT2020/09/182024/03/15
V3Abstractive Text Summarization with BART2023/07/082024/03/20
V2Pretraining BERT with Hugging Face Transformers2022/07/012022/08/27
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3End-to-end Masked Language Modeling with BERT2020/09/182024/03/15
V3Abstractive Text Summarization with BART2023/07/082024/03/20
V2Pretraining BERT with Hugging Face Transformers2022/07/012022/08/27

Parameter efficient fine-tuning

StarterKeras VersionTitleDate CreatedLast Modified
V3Parameter-efficient fine-tuning of GPT-2 with LoRA2023/05/272023/05/27
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Parameter-efficient fine-tuning of GPT-2 with LoRA2023/05/272023/05/27

Other

StarterKeras VersionTitleDate CreatedLast Modified
V2Training a language model from scratch with 🤗 Transformers and TPUs2023/05/212023/05/21
V2MultipleChoice Task with Transfer Learning2023/09/142023/09/14
V2Question Answering with Hugging Face Transformers2022/01/132022/01/13
V2Abstractive Summarization with Hugging Face Transformers2022/07/042022/08/28
StarterKeras VersionTitleDate CreatedLast Modified ▼
V2MultipleChoice Task with Transfer Learning2023/09/142023/09/14
V2Training a language model from scratch with 🤗 Transformers and TPUs2023/05/212023/05/21
V2Abstractive Summarization with Hugging Face Transformers2022/07/042022/08/28
V2Question Answering with Hugging Face Transformers2022/01/132022/01/13

Structured Data

Structured data classification

StarterKeras VersionTitleDate CreatedLast Modified
V3Structured data classification with FeatureSpace2022/11/092022/11/09
V3FeatureSpace advanced use cases2023/07/012023/07/01
V3Imbalanced classification: credit card fraud detection2019/05/282020/04/17
V3Structured data classification from scratch2020/06/092020/06/09
V3Structured data learning with Wide, Deep, and Cross networks2020/12/312021/05/05
V2Classification with Gated Residual and Variable Selection Networks2021/02/102021/02/10
V2Classification with TensorFlow Decision Forests2022/01/252022/01/25
V3Classification with Neural Decision Forests2021/01/152021/01/15
V3Structured data learning with TabTransformer2022/01/182022/01/18
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3FeatureSpace advanced use cases2023/07/012023/07/01
V3Structured data classification with FeatureSpace2022/11/092022/11/09
V2Classification with TensorFlow Decision Forests2022/01/252022/01/25
V3Structured data learning with TabTransformer2022/01/182022/01/18
V3Structured data learning with Wide, Deep, and Cross networks2020/12/312021/05/05
V2Classification with Gated Residual and Variable Selection Networks2021/02/102021/02/10
V3Classification with Neural Decision Forests2021/01/152021/01/15
V3Structured data classification from scratch2020/06/092020/06/09
V3Imbalanced classification: credit card fraud detection2019/05/282020/04/17

Recommendation

StarterKeras VersionTitleDate CreatedLast Modified
V3Collaborative Filtering for Movie Recommendations2020/05/242020/05/24
V3A Transformer-based recommendation system2020/12/302020/12/30
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3A Transformer-based recommendation system2020/12/302020/12/30
V3Collaborative Filtering for Movie Recommendations2020/05/242020/05/24

Timeseries

Timeseries classification

StarterKeras VersionTitleDate CreatedLast Modified
V3Timeseries classification from scratch2020/07/212023/11/10
V3Timeseries classification with a Transformer model2021/06/252021/08/05
V3Electroencephalogram Signal Classification for action identification2022/11/032022/11/05
V3Event classification for payment card fraud detection2024/02/012024/02/01
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Event classification for payment card fraud detection2024/02/012024/02/01
V3Timeseries classification from scratch2020/07/212023/11/10
V3Electroencephalogram Signal Classification for action identification2022/11/032022/11/05
V3Timeseries classification with a Transformer model2021/06/252021/08/05

Anomaly detection

StarterKeras VersionTitleDate CreatedLast Modified
V3Timeseries anomaly detection using an Autoencoder2020/05/312020/05/31
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Timeseries anomaly detection using an Autoencoder2020/05/312020/05/31

Timeseries forecasting

StarterKeras VersionTitleDate CreatedLast Modified
V3Traffic forecasting using graph neural networks and LSTM2021/12/282023/11/22
V3Timeseries forecasting for weather prediction2020/06/232023/11/22
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Traffic forecasting using graph neural networks and LSTM2021/12/282023/11/22
V3Timeseries forecasting for weather prediction2020/06/232023/11/22

Generative Deep Learning

Image generation

StarterKeras VersionTitleDate CreatedLast Modified
V3Denoising Diffusion Implicit Models2022/06/242022/06/24
V3A walk through latent space with Stable Diffusion2022/09/282022/09/28
V2DreamBooth2023/02/012023/02/05
V2Denoising Diffusion Probabilistic Model2022/11/302022/12/07
V2Teach StableDiffusion new concepts via Textual Inversion2022/12/092022/12/09
V2Fine-tuning Stable Diffusion2022/12/282023/01/13
V3Variational AutoEncoder2020/05/032024/04/24
V3DCGAN to generate face images2019/04/292023/12/21
V3WGAN-GP overriding `Model.train_step`2020/05/092023/08/03
V3Conditional GAN2021/07/132024/01/02
V3CycleGAN2020/08/122024/09/30
V2Data-efficient GANs with Adaptive Discriminator Augmentation2021/10/282021/10/28
V3Deep Dream2016/01/132020/05/02
V3GauGAN for conditional image generation2021/12/262022/01/03
V3PixelCNN2020/05/172020/05/23
V2Face image generation with StyleGAN2021/07/012021/12/20
V2Vector-Quantized Variational Autoencoders2021/06/272021/07/21
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3CycleGAN2020/08/122024/09/30
V3Variational AutoEncoder2020/05/032024/04/24
V3Conditional GAN2021/07/132024/01/02
V3DCGAN to generate face images2019/04/292023/12/21
V3WGAN-GP overriding `Model.train_step`2020/05/092023/08/03
V2DreamBooth2023/02/012023/02/05
V2Fine-tuning Stable Diffusion2022/12/282023/01/13
V2Teach StableDiffusion new concepts via Textual Inversion2022/12/092022/12/09
V2Denoising Diffusion Probabilistic Model2022/11/302022/12/07
V3A walk through latent space with Stable Diffusion2022/09/282022/09/28
V3Denoising Diffusion Implicit Models2022/06/242022/06/24
V3GauGAN for conditional image generation2021/12/262022/01/03
V2Face image generation with StyleGAN2021/07/012021/12/20
V2Data-efficient GANs with Adaptive Discriminator Augmentation2021/10/282021/10/28
V2Vector-Quantized Variational Autoencoders2021/06/272021/07/21
V3PixelCNN2020/05/172020/05/23
V3Deep Dream2016/01/132020/05/02

Style transfer

StarterKeras VersionTitleDate CreatedLast Modified
V3Neural style transfer2016/01/112020/05/02
V2Neural Style Transfer with AdaIN2021/11/082021/11/08
StarterKeras VersionTitleDate CreatedLast Modified ▼
V2Neural Style Transfer with AdaIN2021/11/082021/11/08
V3Neural style transfer2016/01/112020/05/02

Text generation

StarterKeras VersionTitleDate CreatedLast Modified
V3GPT2 Text Generation with KerasHub2023/04/122023/04/17
V3GPT text generation from scratch with KerasHub2022/07/252022/07/25
V3Text generation with a miniature GPT2020/05/292020/05/29
V3Character-level text generation with LSTM2015/06/152020/04/30
V2Text Generation using FNet2021/10/052021/10/05
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3GPT2 Text Generation with KerasHub2023/04/122023/04/17
V3GPT text generation from scratch with KerasHub2022/07/252022/07/25
V2Text Generation using FNet2021/10/052021/10/05
V3Text generation with a miniature GPT2020/05/292020/05/29
V3Character-level text generation with LSTM2015/06/152020/04/30

Graph generation

StarterKeras VersionTitleDate CreatedLast Modified
V2Drug Molecule Generation with VAE2022/03/102022/03/24
V2WGAN-GP with R-GCN for the generation of small molecular graphs2021/06/302021/06/30
StarterKeras VersionTitleDate CreatedLast Modified ▼
V2Drug Molecule Generation with VAE2022/03/102022/03/24
V2WGAN-GP with R-GCN for the generation of small molecular graphs2021/06/302021/06/30

Other

StarterKeras VersionTitleDate CreatedLast Modified
V2A walk through latent space with Stable Diffusion 32024/11/112024/11/11
V2Density estimation using Real NVP2020/08/102020/08/10
StarterKeras VersionTitleDate CreatedLast Modified ▼
V2A walk through latent space with Stable Diffusion 32024/11/112024/11/11
V2Density estimation using Real NVP2020/08/102020/08/10

Audio Data

Speech recognition

StarterKeras VersionTitleDate CreatedLast Modified
V3Automatic Speech Recognition with Transformer2021/01/132021/01/13
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Automatic Speech Recognition with Transformer2021/01/132021/01/13

Other

StarterKeras VersionTitleDate CreatedLast Modified
V2Automatic Speech Recognition using CTC2021/09/262021/09/26
V2MelGAN-based spectrogram inversion using feature matching2021/09/022021/09/15
V2Speaker Recognition2020/06/142023/07/19
V2Audio Classification with the STFTSpectrogram layer2024/10/042024/10/04
V2English speaker accent recognition using Transfer Learning2022/04/162022/04/16
V2Audio Classification with Hugging Face Transformers2022/07/012022/08/27
StarterKeras VersionTitleDate CreatedLast Modified ▼
V2Audio Classification with the STFTSpectrogram layer2024/10/042024/10/04
V2Speaker Recognition2020/06/142023/07/19
V2Audio Classification with Hugging Face Transformers2022/07/012022/08/27
V2English speaker accent recognition using Transfer Learning2022/04/162022/04/16
V2Automatic Speech Recognition using CTC2021/09/262021/09/26
V2MelGAN-based spectrogram inversion using feature matching2021/09/022021/09/15

Reinforcement Learning

StarterKeras VersionTitleDate CreatedLast Modified
V3Actor Critic Method2020/05/132024/02/22
V3Proximal Policy Optimization2021/06/242024/03/12
V3Deep Q-Learning for Atari Breakout2020/05/232024/03/16
V3Deep Deterministic Policy Gradient (DDPG)2020/06/042024/03/23
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Deep Deterministic Policy Gradient (DDPG)2020/06/042024/03/23
V3Deep Q-Learning for Atari Breakout2020/05/232024/03/16
V3Proximal Policy Optimization2021/06/242024/03/12
V3Actor Critic Method2020/05/132024/02/22

Graph Data

StarterKeras VersionTitleDate CreatedLast Modified
V2Graph attention network (GAT) for node classification2021/09/132021/12/26
V2Node Classification with Graph Neural Networks2021/05/302021/05/30
V2Message-passing neural network (MPNN) for molecular property prediction2021/08/162021/12/27
V2Graph representation learning with node2vec2021/05/152021/05/15
StarterKeras VersionTitleDate CreatedLast Modified ▼
V2Message-passing neural network (MPNN) for molecular property prediction2021/08/162021/12/27
V2Graph attention network (GAT) for node classification2021/09/132021/12/26
V2Node Classification with Graph Neural Networks2021/05/302021/05/30
V2Graph representation learning with node2vec2021/05/152021/05/15

Quick Keras Recipes

Keras usage tips

StarterKeras VersionTitleDate CreatedLast Modified
V3Parameter-efficient fine-tuning of Gemma with LoRA and QLoRA2024/08/062024/08/06
V3Float8 training and inference with a simple Transformer model2024/05/142024/05/14
V3Keras debugging tips2020/05/162023/11/16
V3Customizing the convolution operation of a Conv2D layer2021/03/112021/03/11
V3Trainer pattern2022/09/192022/09/26
V3Endpoint layer pattern2019/05/102023/11/22
V3Reproducibility in Keras Models2023/05/052023/05/05
V3Writing Keras Models With TensorFlow NumPy2021/08/282021/08/28
V3Simple custom layer example: Antirectifier2016/01/062023/11/20
V3Packaging Keras models for wide distribution using Functional Subclassing2023/12/132023/12/13
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Parameter-efficient fine-tuning of Gemma with LoRA and QLoRA2024/08/062024/08/06
V3Float8 training and inference with a simple Transformer model2024/05/142024/05/14
V3Packaging Keras models for wide distribution using Functional Subclassing2023/12/132023/12/13
V3Endpoint layer pattern2019/05/102023/11/22
V3Simple custom layer example: Antirectifier2016/01/062023/11/20
V3Keras debugging tips2020/05/162023/11/16
V3Reproducibility in Keras Models2023/05/052023/05/05
V3Trainer pattern2022/09/192022/09/26
V3Writing Keras Models With TensorFlow NumPy2021/08/282021/08/28
V3Customizing the convolution operation of a Conv2D layer2021/03/112021/03/11

Serving

StarterKeras VersionTitleDate CreatedLast Modified
V3Serving TensorFlow models with TFServing2023/01/022023/01/02
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Serving TensorFlow models with TFServing2023/01/022023/01/02

ML best practices

StarterKeras VersionTitleDate CreatedLast Modified
V3Estimating required sample size for model training2021/05/202021/06/06
V3Memory-efficient embeddings for recommendation systems2021/02/152023/11/15
V3Creating TFRecords2021/02/272023/12/20
StarterKeras VersionTitleDate CreatedLast Modified ▼
V3Creating TFRecords2021/02/272023/12/20
V3Memory-efficient embeddings for recommendation systems2021/02/152023/11/15
V3Estimating required sample size for model training2021/05/202021/06/06

Other

StarterKeras VersionTitleDate CreatedLast Modified
V2Approximating non-Function Mappings with Mixture Density Networks2023/07/152023/07/15
V2Probabilistic Bayesian Neural Networks2021/01/152021/01/15
V2Knowledge distillation recipes2021/08/012021/08/01
V2Evaluating and exporting scikit-learn metrics in a Keras callback2021/10/072023/11/17
V2How to train a Keras model on TFRecord files2020/07/292020/08/07
StarterKeras VersionTitleDate CreatedLast Modified ▼
V2Evaluating and exporting scikit-learn metrics in a Keras callback2021/10/072023/11/17
V2Approximating non-Function Mappings with Mixture Density Networks2023/07/152023/07/15
V2Knowledge distillation recipes2021/08/012021/08/01
V2Probabilistic Bayesian Neural Networks2021/01/152021/01/15
V2How to train a Keras model on TFRecord files2020/07/292020/08/07

Adding a new code example

We welcome new code examples! Here are our rules:

  • They should be shorter than 300 lines of code (comments may be as long as you want).
  • They should demonstrate modern Keras best practices.
  • They should be substantially different in topic from all examples listed above.
  • They should be extensively documented & commented.

New examples are added via Pull Requests to the keras.io repository. They must be submitted as a .py file that follows a specific format. They are usually generated from Jupyter notebooks. See the tutobooks documentation for more details.

If you would like to convert a Keras 2 example to Keras 3, please open a Pull Request to the keras.io repository.