Skip to content

Instantly share code, notes, and snippets.

@dpoulopoulos
Created January 20, 2022 14: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 dpoulopoulos/554f6dcd45a2d4566566c5e8c4c07539 to your computer and use it in GitHub Desktop.
Save dpoulopoulos/554f6dcd45a2d4566566c5e8c4c07539 to your computer and use it in GitHub Desktop.
strategy = tf.distribute.MirroredStrategy()
BATCH_SIZE = 64
GLOBAL_BATCH_SIZE = BATCH_SIZE * strategy.num_replicas_in_sync
train_data = tf.data.Dataset(...).batch(GLOBAL_BATCH_SIZE)
with strategy.scope():
model = tf.keras.Sequential(...)
model.compile(...)
model.fit(train_data, epochs=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment