Skip to content

Instantly share code, notes, and snippets.

@sayakpaul
Created May 2, 2020 02:39
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/00c0b6ab257ff5df65e6972bf9036777 to your computer and use it in GitHub Desktop.
Save sayakpaul/00c0b6ab257ff5df65e6972bf9036777 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),
# Softmax should be done in float32 for numeric stability.
tf.keras.layers.Activation('Softmax', dtype='float32')
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment