Skip to content

Instantly share code, notes, and snippets.

@sayakpaul
Created May 2, 2020 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sayakpaul/37ff985295c74d186b0cf6e5a492efa1 to your computer and use it in GitHub Desktop.
Save sayakpaul/37ff985295c74d186b0cf6e5a492efa1 to your computer and use it in GitHub Desktop.
policy = tf.keras.mixed_precision.experimental.Policy('mixed_float16')
model = tf.keras.models.Sequential(
tf.keras.layers.Input((100,)),
tf.keras.layers.Dense(10, dtype=policy),
tf.keras.layers.Dense(10, dtype=policy),
# Softmax should be done in float32 for numeric stability.
tf.keras.layers.Activation('Softmax', dtype='float32')
)
model.fit(...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment