In this guide, we learn how to develop a TensorFlow model and serve it on the Google Cloud Platform (GCP). We consider a regression problem of predicting the earnings of products using a three-layer neural network implemented with TensorFlow and Keras APIs.The key learning outcomes of this guide are

  1. Build, compile and fit Model in TensorflowSet up tensorboard in Google colabSave, load and predict on unseen dataDeploy the TensorFlow model on Google Cloud platform

In this guide, we will use the TensorFlow 2.1.0 and Google colab runtime environment. We will be using the google colab for training the models using TensorFlow and Keras APIS. Starting from TensorFlow 2.0, Keras is now part of the TensorFlow package. Google colab offers the training of machine learning models on free GPU and TPU. Therefore, it is recommended the environment to get hands-on experience of training your deep learning models on GPU and TPU. Moreover, we can set up tensorboard to get a better understanding of the model training. This guide comes with a working copy of Google colab to get you started quickly.

# Install TensorFlow >2.0
!pip install tensorflow==2.1.0

Import the necessary python libraries along with TensorFlow and Keras functions

# Import libraries
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
import os
import numpy as np
from __future__ import absolute_import, division, print_function, unicode_literals

import tensorflow as tf

from tensorflow.keras.layers import Dense, Flatten, Conv2D
from tensorflow.keras import Model
from tensorflow.keras.models import Sequential, load_model

Load the tensorboard extension

# Load tensorboard 
%load_ext tensorboard

Mounting the Gdrive for dataTo access the data in Google colab environment, there are various ways to do it. One of my favourite is to upload data to your Google Drive and mount Google Drive in colab.

#tensorflow #python #data-science #machine-learning #google-cloud-platform

Model with TensorFlow and Serve on Google Cloud Platform
1.45 GEEK