Welcome to the AI Platform Training and Prediction sample code repository. This repository contains samples for how to use AI Platform for model training and serving.
Attention: Visit our new Vertex AI repo vertex-ai-samples
- ML on GCP, which has guides on how to bring your code from various ML frameworks to Google Cloud Platform using things like Google Compute Engine or Kubernetes.
- Keras Idiomatic Programmer This repository contains content produced by Google Cloud AI Developer Relations for machine learning and artificial intelligence. The content covers a wide spectrum from educational, training, and research, covering from novices, junior/intermediate to advanced.
- Professional Services, common solutions and tools developed by Google Cloud's Professional Services team.
The repository is organized by tasks:
Each task can be broken down to general usage (CPU/GPU)
to specific features:
Scroll down to see what we have available, each task may provide a notebook or code solution. Where the code solution will have a README
guide and the notebook solution is a full walkthrough. Our code guides are designed to provide you with the code and instructions on how to run the code, but leave you to do the digging, where our notebook tutorials try to walk you through the whole process by having the code available in the notebook throughout the guide.
If you don’t see something for the task you’re trying to complete, please head down to our section What do you want to see?
For installation instructions and overview, please see the documentation. Please refer to README.md
in each sample directory for more specific instructions.
If this is your first time using AI Platform, we suggest you take a look at the Introduction to AI Platform docs to get started.
- scikit-learn: Random Forest Classifier - How to train a Random Forest Classifier in scikit-learn using a text based dataset, Census, to predict a person’s income level.
- XGBoost - How to train an XGBoost model using a text based dataset, Census, to predict a person’s income level.
- Tensorflow: Linear Classifier with Stochastic Dual Coordinate Ascent (SDCA) Optimizer / Deep Neural Network Classifier - How to train a Linear Classifier with SDCA and a DNN using a text (discrete feature) based dataset, Criteo, to predict how likely a person is to click on an advertisement.
- Tensorflow: Linear Regression with Stochastic Dual Coordinate Ascent (SDCA) / Deep Neural Network Regressor - How to train a Linear Regressor with SDCA and a DNN using the a text based dataset of Reddit Comments to predict the score of a Reddit thread using a wide and deep model.
- Tensorflow: ResNet - How to train a model for image recognition using the CIFAR10 dataset to classify image content (training on one CPU, a single host with multiple GPUs, and multiple hosts with CPU or multiple GPUs).
Tensor Processing Units (TPUs) are Google’s custom-developed ASICs used to accelerate machine-learning workloads. You can run your training jobs on AI Platform, using Cloud TPU.
- Tensorflow: ResNet - Using the ImageNet dataset with Cloud TPUs on AI Platform.
- Tensorflow: HP Tuning - ResNet - How to run hyperparameter tuning jobs on AI Platform with Cloud TPUs using TensorFlow's tf.metrics.
- Tensorflow: Hypertune - ResNet - How to run hyperparameter tuning jobs on AI Platform with Cloud TPUs using the cloudml-hypertune package.
- Tensorflow: Cloud TPU Templates - A collection of minimal templates that can be run on Cloud TPUs on Compute Engine, Cloud Machine Learning, and Colab.
- scikit-learn: Lasso Regressor - How to train a Lasso Regressor in scikit-learn using a text based dataset, auto mpg, to predict a car's miles per gallon.
- XGBoost: XGBRegressor - How to train a Regressor in XGBoost using a text based dataset, auto mpg, to predict a car's miles per gallon.
- Keras: Sequential / Dense - How to train a Keras model using the Nightly Build of TensorFlow on AI Platform using a structured dataset, sonar signals, to predict whether the given sonar signals are bouncing off a metal cylinder or off a cylindrical rock.
- PyTorch: Deep Neural Network - How to train a PyTorch model on AI Platform using a custom container with a image dataset, mnist, to classify handwritten digits.
- PyTorch: Sequential - How to train a PyTorch model on AI Platform using a custom container with a structured dataset, sonar signals, to predict whether the given sonar signals are bouncing off a metal cylinder or off a cylindrical rock.
- PyTorch: Sequential / HP Tuning - How to train a PyTorch model on AI Platform using a custom container and Hyperparameter Tuning with a structured dataset, sonar signals, to predict whether the given sonar signals are bouncing off a metal cylinder or off a cylindrical rock.
- scikit-learn: Model Serving - How to train a Random Forest Classifier in scikit-learn on your local machine using a text based dataset, Census, to predict a person’s income level and deploy it on AI Platform to create predictions.
- XGBoost: Model Serving - How to train an XGBoost model on your local machine using a text based dataset, Census, to predict a person’s income level and deploy it on AI Platform to create predictions.
- Tensorflow: Deep Neural Network Regressor - How to train a DNN on a text based molecular dataset from Kaggle to predict the molecular energy.
- Tensorflow: Softmax / Fully-connected layer - How to train a fully connected model with softmax using an image dataset of flowers to recognize the type of a flower from its image.
- Keras: Sequential / Dense - Keras - How to train a Keras sequential and Dense model using a text based dataset, Census, to predict a person’s income level using a single node model.
- Tensorflow Pre-made Estimator: Deep Neural Network Linear Combined Classifier -How to train a DNN using Tensorflow’s Pre-made Estimators using a text based dataset, Census, to predict a person’s income level. TensorFlow Pre-made Estimator, an estimator is “a high-level TensorFlow API that greatly simplifies machine learning programming.”
- Tensorflow Custom Estimator: Deep Neural Network - How to train a DNN using Tensorflow’s Custom Estimators using a text based dataset, Census, to predict a person’s income level. TensorFlow Custom Estimator, which is when you write your own model function.
- Tensorflow: Deep Neural Network - How to train a DNN using TensorFlow’s low level APIs to create your DNN model on a single node using a text based dataset, Census, to predict a person’s income level.
- Tensorflow: Matrix Factorization / Deep Neural Network with Softmax - How to train a Matrix Factorization and DNN with Softmax using a text based dataset, MovieLens 20M, to make movie recommendations.
-
TensorFlow Estimator Trainer Package Template - When training a Tensorflow model, you have to create a trainer package, here we have a template that simplifies creating a trainer package for AI Platform. Take a look at this list with some introductory examples.
-
Tensorflow: Cloud TPU Templates - A collection of minimal templates that can be run on Cloud TPUs on Compute Engine, Cloud Machine Learning, and Colab.
-
Scikit-learn Pipelines Trainer Package Template - You can use this as starter code to develop a scikit-learn model for training and prediction on AI Platform. Examples to be added.
Please see the Cloud TPU guide for how to use Cloud TPU.
-
- Genomics Ancestry Inference - Genomics ancestry inference using 1000 Genomes dataset
If you came looking for a sample we don’t have, please file an issue using the Sample / Feature Request template on this repository. Please provide as much detail as possible about the AI Platform sample you were looking for, what framework (Tensorflow, Keras, scikit-learn, XGBoost, PyTorch...), the type of model, and what kind of dataset you were hoping to use!
Jump below if you want to contribute and add that missing sample.
We welcome external sample contributions! To learn more about contributing new samples, checkout our CONTRIBUTING.md guide. Please feel free to add new samples that are built in notebook form or code form with a README guide.
Want to contribute but don't have an idea? Check out our Sample Request Page and assign the issue to yourself so we know you're working on it!
We host AI Platform documentation here
The content in the CloudML-Samples
repository is not officially maintained by Google.