Build a handwritten digit recognizer in Watson Studio and PyTorch


Recognizing handwritten numbers is a piece of cake for humans, but it’s a non-trivial task for machines. Currently, however, with the advancement of machine learning, people have made machines more capable of performing this task. We now have mobile banking apps that can scan checks in seconds, and accounting software that can extract dollar amounts from thousands of contracts in minutes. If you are interested in knowing how this all works, please follow along with this code pattern as we take you through the steps to create a simple handwritten digit recognizer in Watson Studio and PyTorch.


In this code pattern, you’ll use Jupyter Notebook in IBM Watson Studio to access pre-installed and optimized PyTorch environments through Python client library of Watson Machine Learning Service. The library has a set of REST APIs in its core that allow you to submit training jobs, monitor status, store, and deploy models.

When you have completed this code pattern, you’ll understand how to:

  • Create a project in Watson Studio and use Jupyter Notebook in the project.
  • Use Python client of Cloud Object Storage to create buckets and upload data to buckets.
  • Submit PyTorch training jobs to Watson Machine Learning Service.
  • Use trained PyTorch model to predict handwritten digits from images.



  1. Log into IBM Watson Studio.
  2. Run the Jupyter Notebook in Watson Studio.
  3. Use PyTorch to download and process the data.
  4. Use Watson Machine Learning to train and deploy the model.


Get the detailed instructions in the README file. These steps will show you how to:

  1. Sign up for Watson Studio.
  2. Create a new project.
  3. Create the notebook.
  4. Create a Watson Machine Learning Service instance.
  5. Create HMAC credentials for the Watson Object Storage instance.
  6. Run the notebook.