A Must-Have Tool for Every Data Scientist

TensorDash — An app to remotely monitor your Machine Learning models

Arun
Towards Data Science

--

Photo by Luke Chesser on Unsplash

Let's face it; training a machine learning model is time-consuming. Even with the advancement in computing prowess over the past few years, training machine learning models takes a lot of time. Even the most trivial models have more than a million parameters. On a bigger scale, these models have over a billion parameters(GPT-3 has over 175 billion parameters!), and training these models takes days, if not weeks. As a Data Scientist, we would want to keep an eye on the model’s metrics to know if the model performs as per expectations. But it doesn’t make sense to sit next to your computer, monitoring the metrics for hours. Won’t it be nice if we could get all this data on your phone?

When was the last time you let your model train for hours and left the place, but your model had crashed halfway when you came back? This is frustrating and a complete waste of time. Since most people do not have the horsepower to train machine learning models locally, cloud services like GCP, Google Colab, AWS, and Azure are preferred where users pay as per their usage. In this case, if the model has crashed in-between training, you are paying for the service without using it. It will help you avoid FOMO if you are notified about your model status.

TensorDash

TensorDash is a free to use open-source app that lets you remotely monitor your machine learning models through detailed graphs of all your metrics. It also notifies you when the training has been completed or if the model has crashed. It supports all the major machine learning frameworks like TensorFlow, Pytorch, Keras, and Fastai.

Now you don’t have to be stressed sitting in front of your computer, praying for the accuracy to increase. You can do that from the comfort of your home.

TensorDash Sample (Image by Author)

Using TensorDash

  1. Install the TensorDash app from the play store. Support for iOS devices is coming soon.
  2. Create an account.
  3. Install the TensorDash python package using the command pip install tensor-dash.
  4. Follow the instructions below for using TensorDash with your respective framework.

Keras/tf.keras Support

Remote monitoring with Keras and tf.keras works using the callback function. Import Tensordash. Define a TensorDash object using the model name, your account email ID, and password as the parameters. Pass the TensorDash object via callbacks in the fit() function. To get notified if your model crashes, add the fit() function under exception handling, and in the except, call the sendCrash() method.

Below is the sample code for using TensorDash on Keras/tf.keras

Sample Keras/tf.keras code

PyTorch Support

Import Torchdash from the Tensordash package. Create a Torchdash object with the model name, email ID, and password as the parameters. Use the sendLoss() method of the object inside the training loop to send the model metrics to your account. Pass the loss, accuracy, validation loss, and validation accuracy metrics as parameters(Note that you have to add at least one metric). To get notified if your model crashes, add the training loop under exception handling, and in the except, call the sendCrash() method.

Below is the sample code for using TensorDash on PyTorch

Sample PyTorch code

Fast.ai Support

Remote monitoring with fast.ai works through callbacks. Import Fastdash. Define a Fastdash object using the model name, your account email ID, and password as the parameters. Pass the Fastdash object via callbacks in the fit() function. To get notified if your model crashes, add the fit() function under exception handling, and in the except, call the sendCrash() method.

Below is the sample code for using Fast.ai

Sample fast.ai code

TensorFlow Support

Import Customdash from the Tensordash package. Create a Customdash object with the model name, email ID, and password as the parameters. Use the sendLoss() method of the object inside the training loop to send the model metrics to your account. Pass the loss, accuracy, validation loss, and validation accuracy metrics as parameters(Note that you have to add at least one metric). To get notified if your model crashes, add the training loop under exception handling, and in the except, call the sendCrash() method.

Note that Customdash can be used with any framework where you specify a custom training loop.

Below is the sample code for using TensorDash on a TensorFlow custom loop

Sample TensorFlow code

Conclusion

TensorDash is completely free and open-source. Issues and contributions are welcome. Check out the repository here and the detailed docs here.

Harshit Maheshwari and I built this tool to solve our monitoring problems during AI research. I hope this helps you just as well as it helped us.

About Me

I like to write about some lesser talked about topics in AI. Follow me to stay updated.

You can find me on Twitter, LinkedIn, and Github.

--

--