Now, let's look at the code that trains on this data. At the top of the program, we have our usual imports, together with three extra ones that may need installing with pip – tensorflow_hub, pandas, and seaborn. As we mentioned previously, we will be using a module from tensorflow_hub; we will also be using some DataFrame properties of pandas and some plotting methods of seaborn:
import tensorflow as tfimport tensorflow_hub as hubimport matplotlib.pyplot as pltimport numpy as npimport osimport pandas as pdimport reimport seaborn as sns
Also, here are some values and a method we need later:
n_classes = 2hidden_units = [500,100]learning_rate = 1e-4steps = 1000optimizer = tf.optimizers.Adagrad(learning_rate=learning_rate)# upgrade script ...