Last active
August 17, 2019 01:24
-
-
Save rish-16/35bcc747ece7643c3d225f53dda5eadb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| with strategy.scope(): | |
| """ | |
| This essentailly takes our model and makes it | |
| compatible to train on a TPU. | |
| """ | |
| model = tf.keras.models.Sequential() | |
| model.add(tf.keras.layers.Dense(512, input_size=[784,], activation='relu')) | |
| model.add(tf.keras.layers.Dense(256, activation='relu')) | |
| model.add(tf.keras.layers.Dense(128, activation='relu')) | |
| model.add(tf.keras.layers.Dense(64, activation='relu')) | |
| model.add(tf.keras.layers.Dense(10, activation='softmax')) | |
| """ | |
| Compiling the model using the RMSProp optimizer | |
| and Sparse Categorical Crossentropy loss | |
| """ | |
| model.compile( | |
| optimizer=tf.train.RMSPropOptimizer(learning_rate=1e-2), | |
| loss=tf.keras.losses.sparse_categorical_crossentropy, | |
| metrics=['sparse_categorical_accuracy'] | |
| ) | |
| model.summary() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment