Keeping the track of progress while training ML models

Keeping the track of progress while training ML models

·

2 min read

Usually keeping track while training the model is a tedious task it requires lot's of effort, callbacks, plotting metrics , visualizing data storing the results to drive, and much more things are required

After that saving model is a different task with collab disconnecting frequently and not being able to restore previous progress the building and working on the task for creating model becomes more hectic

solution

here comes the part while find the solution for the above problem while saving our model's progress, visualizing while it's training plotting the matrics at the same time and again saving the model automatically after finishing the training all these things seems a lot of stuff but there is one way that automates all of this stuff for us :)

image.png All of this we can do through with the help of wandb.ai they have their callback for the specific libraries and even if you want to log anything onto your profile you can do it in just 1 line :)

image.png

let's see how can we include this in our notebook

if you are doing training of your model either by TensorFlow or by PyTorch

!pip install wandb
import wandb 
wandb.login()

here we are using above lines for logging into our wandb account (you have to create wandb account with wandb.ai if you are new to wandb)

after doing this if you are using Tensorflow you can import the callback by using

from wandb.keras import WandbCallback

if you are using the PyTorch you can do keep watch on our model by using

wandb.watch(model, log_freq=100)

here the log_freq=100 indicates how many batches after wandb is gonna log our matrix

along with the essential metrics wandb stores the system performance metrics in case runtime failure happens and you need to check the status of your system

image.png

we can also specify the which model to save for saving the model in wandb storage all we have to do is

wandb.save('model_dir')

for downloading the same model on the notebook again we can do it with the help of

best_model = wandb.restore(
  'model-best.h5', run_path="vanpelt/my-project/a1b2c3d")

Although there are many features wandb offers such as artifacts, creating the reports, storing the datasets, visualizing datasets, and much more we will cover those in coming blog posts :) that's all for this post I am gonna post more about wandb and more stuff in coming blog posts

thanks for reading my blog :) follow for more say hi to me in comments it gives me encouragement for writing more blogs :) have a good day :)