VOOZH about

URL: https://www.analyticsvidhya.com/blog/2021/03/improving-your-deep-learning-model-using-model-checkpointing-part-1/

โ‡ฑ Improving your Deep Learning model using Model Checkpointing- Part 1


India's Most Futuristic AI Conference Is Back โ€“ Bigger, Sharper, Bolder

  • d
  • :
  • h
  • :
  • m
  • :
  • s

Reading list

Improving your Deep Learning model using Model Checkpointing- Part 1

Himanshi Singh Last Updated : 18 Mar, 2021
5 min read

Introduction

Deep learning is ubiquitous โ€“ whether itโ€™s Computer Vision applications or breakthroughs in the field of Natural Language Processing, we are living in a deep learning-fueled world. Thanks to the rapid advances in technology, more and more people are able to leverage the power of deep learning. At the same time, it is a complex field and can appear daunting for newcomers.

Note: If you are more interested in learning concepts in an Audio-Visual format, We have this entire article explained in the video below. If not, you may continue reading.

One common concern for everyone in this field is- How can they improve their Deep Learning models? Are there any ways or techniques which can help them to improve their models? Well, there certainly are such techniques which you need to know if you also want to improve your model performance. And in this article, Iโ€™m going to cover one of such techniques, which I must say is very important while building a Neural Network. This technique is called Model Checkpointing. And it majorly has two advantages-

  • Saves the best model for us.
  • In case of system failure, not everything is lost

Weโ€™ll discuss each one in detail. Letโ€™s begin!

1. Saving the Best Model

Letโ€™s discuss what do we mean by โ€œBest Modelโ€ and how it can be saved? Letโ€™s say that this is the visualization of the performance of a model-

๐Ÿ‘ Model Checkpointing - Saving the Best Model

Here the blue line represents the training loss and the orange line represents the validation loss. On the X-axis, we have the number of epochs and on the Y-axis we have the loss values. Now, while making the predictions, the weights and biases stored at the very last epoch will be used. So the model will train completely till the specified number of epochs, which is 50 in this case. And the parameters learned during the last epoch will be used in order to make the predictions.

๐Ÿ‘ model checkpointing - epoch vs loss

But if you look closely in this particular graph, the best validation loss is around this epoch, which is epoch number 45-

๐Ÿ‘ best validation loss

Let me take the model history in order to elaborate on this a bit more. So here is the model history for a model which has been trained for 50 epochs-

๐Ÿ‘ Model Checkpointing - 50 epochs

And you can see the epoch numbers here. Now we can see that we have the training loss, training accuracy, validation loss, and validation accuracy shown here. Letโ€™s look at the valuation loss as highlighted here-

๐Ÿ‘ Model Checkpointing - valuation loss

So what we generally do is we take the parameters of the model at the last epoch, which is epoch 50 here, and make the predictions. Now, in this case, we can see that the valuation loss at epoch number 50 is 0.629, whereas if you see the lowest validation loss was 0.61, which was at epoch 45.

๐Ÿ‘ Model Checkpointing - 45 epochs

So through the model checkpointing, instead of saving the last model or the parameters of the last epoch, we are going to save the model which produces the best results. And this model is called the Best Model. So basically Model Checkpointing will help us save the best model.

2- In case of system failure, not everything is lost

Now, since it seems the best model, the second useful advantage of this technique is that in case your system breaks or fails during the training process, you will not lose much information since the model is being saved constantly. Now, we know that through model checkpointing, we can save the best model but you must be wondering, how do we do that? How do we know which model is the best model?

So to answer that in Keras, we have to define two parameters. One is โ€œMonitorโ€ and the other one is โ€œModeโ€.

๐Ÿ‘ Monitor and Model

The first one refers to the quantity that we wish to monitor, such as validation loss or validation accuracy and โ€œModeโ€ refers to the mode of that quantity. Let me explain this with an example. So letโ€™s say we wish to monitor the validation loss in this case. While we are monitoring the validation loss, the mode will be minimum because we want to minimize the loss.

๐Ÿ‘ validation loss

Similarly, if we are monitoring the validation accuracy, the mode will be maximum since we want the maximum accuracy for the validation set.

๐Ÿ‘ validation accuracy

So after every epoch, we will monitor either the validation loss or the validation accuracy and save the model, if these values have improved from the previous model.

Now, these are the common steps that we perform while creating any deep learning model, and we setup model checkpointing at the time of Model Training-

    1. Loading the dataset
    2. Pre-processing the data
    3. Creating training and validation set
    4. Defining the model architecture
    5. Compiling the model
    6. Training the model
    1. Setting up model checkpointing
    7. Evaluating model performance

End Notes

After reading this article you should have got an intuition behind the Model Checkpointing technique which can be really helpful and can do wonders if youโ€™re looking forward to improving your deep learning model. For the implementation of this technique, stay tuned! Iโ€™m going to cover its implementation in the next article.

If you are looking to kick start your Data Science Journey and want every topic under one roof, your search stops here. Check out Analytics Vidhyaโ€™s Certified AI & ML BlackBelt Plus Program

If you have any questions, let me know in the comments section!

Iโ€™m a data lover who enjoys finding hidden patterns and turning them into useful insights. As the Manager - Content and Growth at Analytics Vidhya, I help data enthusiasts learn, share, and grow together. 

Thanks for stopping by my profile - hope you found something you liked :)

Login to continue reading and enjoy expert-curated content.

Free Courses

Ensemble Learning and Ensemble Learning Techniques

Learn ensemble learning, its techniques, and how it works in this course!

Dimensionality Reduction for Machine Learning

Master key dimensionality reduction techniques for ML success!

Responses From Readers

Stephen Cobb

Some of the math is over my head but I do understand most of the concepts.

Flagship Programs

GenAI Pinnacle Program| GenAI Pinnacle Plus Program| AI/ML BlackBelt Program| Agentic AI Pioneer Program

Free Courses

Generative AI| DeepSeek| OpenAI Agent SDK| LLM Applications using Prompt Engineering| DeepSeek from Scratch| Stability.AI| SSM & MAMBA| RAG Systems using LlamaIndex| Building LLMs for Code| Python| Microsoft Excel| Machine Learning| Deep Learning| Mastering Multimodal RAG| Introduction to Transformer Model| Bagging & Boosting| Loan Prediction| Time Series Forecasting| Tableau| Business Analytics| Vibe Coding in Windsurf| Model Deployment using FastAPI| Building Data Analyst AI Agent| Getting started with OpenAI o3-mini| Introduction to Transformers and Attention Mechanisms

Popular Categories

AI Agents| Generative AI| Prompt Engineering| Generative AI Application| News| Technical Guides| AI Tools| Interview Preparation| Research Papers| Success Stories| Quiz| Use Cases| Listicles

Generative AI Tools and Techniques

GANs| VAEs| Transformers| StyleGAN| Pix2Pix| Autoencoders| GPT| BERT| Word2Vec| LSTM| Attention Mechanisms| Diffusion Models| LLMs| SLMs| Encoder Decoder Models| Prompt Engineering| LangChain| LlamaIndex| RAG| Fine-tuning| LangChain AI Agent| Multimodal Models| RNNs| DCGAN| ProGAN| Text-to-Image Models| DDPM| Document Question Answering| Imagen| T5 (Text-to-Text Transfer Transformer)| Seq2seq Models| WaveNet| Attention Is All You Need (Transformer Architecture) | WindSurf| Cursor

Popular GenAI Models

Llama 4| Llama 3.1| GPT 4.5| GPT 4.1| GPT 4o| o3-mini| Sora| DeepSeek R1| DeepSeek V3| Janus Pro| Veo 2| Gemini 2.5 Pro| Gemini 2.0| Gemma 3| Claude Sonnet 3.7| Claude 3.5 Sonnet| Phi 4| Phi 3.5| Mistral Small 3.1| Mistral NeMo| Mistral-7b| Bedrock| Vertex AI| Qwen QwQ 32B| Qwen 2| Qwen 2.5 VL| Qwen Chat| Grok 3

AI Development Frameworks

n8n| LangChain| Agent SDK| A2A by Google| SmolAgents| LangGraph| CrewAI| Agno| LangFlow| AutoGen| LlamaIndex| Swarm| AutoGPT

Data Science Tools and Techniques

Python| R| SQL| Jupyter Notebooks| TensorFlow| Scikit-learn| PyTorch| Tableau| Apache Spark| Matplotlib| Seaborn| Pandas| Hadoop| Docker| Git| Keras| Apache Kafka| AWS| NLP| Random Forest| Computer Vision| Data Visualization| Data Exploration| Big Data| Common Machine Learning Algorithms| Machine Learning| Google Data Science Agent
๐Ÿ‘ Av Logo White

Continue your learning for FREE

Forgot your password?
๐Ÿ‘ Av Logo White

Enter OTP sent to

Edit

Wrong OTP.

Enter the OTP

Resend OTP

Resend OTP in 45s

๐Ÿ‘ Popup Banner
๐Ÿ‘ AI Popup Banner