Created
April 29, 2020 01:17
-
-
Save philipperemy/26b275be2b4d66dd6661f0caa3fae82f to your computer and use it in GitHub Desktop.
This file contains 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
import tensorflow as tf | |
from tensorflow import keras | |
from tensorflow.keras.applications import Xception | |
import numpy as np | |
num_samples = 1000 | |
height = 224 | |
width = 224 | |
num_classes = 1000 | |
strategy = tf.distribute.MirroredStrategy() | |
with strategy.scope(): | |
parallel_model = Xception(weights=None, | |
input_shape=(height, width, 3), | |
classes=num_classes) | |
parallel_model.compile(loss='categorical_crossentropy', optimizer='rmsprop') | |
# Generate dummy data. | |
x = np.random.random((num_samples, height, width, 3)) | |
y = np.random.random((num_samples, num_classes)) | |
parallel_model.summary() | |
# This `fit` call will be distributed on 8 GPUs. | |
# Since the batch size is 256, each GPU will process 32 samples. | |
parallel_model.fit(x, y, epochs=20, batch_size=16) #batch_sized changed to 16 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment