Machine Learning with C++ – Polynomial Regression on GPU

Author: Kyrylo Kolodiazhnyi

Hello, this is my second article about how to use modern C++ for solving machine learning problems. This time I will show how to make a model for polynomial regression problem described in previous article, but now with another library which allows you to use your GPU easily.

For this tutorial I chose MShadow library, you can find documentation for it here. This library was chosen because it is actively developed now, and used as a basis for one of a wide used deep learning framework MXNet. Also it is a header only library with minimal dependencies, so it’s integration is not hard at all.

Continue reading the article and source code here. Please feel free to leave comment or create issue in repository if you find some mistakes.


  1. Preparations
  2. Loading data to MShadow data-structures
  3. Standardization
  4. Generating additional polynomial components
  5. Generating new data for testing model predictions
  6. Batch gradient descent implementation
  7. Training the regression model
  8. Making predictions
  9. Plot results

Go to Source