Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Learning Keras model by using Distributed Tensorflow

I have two GPU installed on two different machines. I want to build a cluster that allows me to learn a Keras model by using the two GPUs together. Keras blog shows two slices of code in Distributed training section and link official Tensorflow documentation.

My problem is that I don't know how to learn my model and put into practice what is reported in Tensorflow documentation. For example, what should I do if I want to execute the following code on a cluster of multiple GPU?

# For a single-input model with 2 classes (binary classification):

model = Sequential()
model.add(Dense(32, activation='relu', input_dim=100))
model.add(Dense(1, activation='sigmoid'))
model.compile(optimizer='rmsprop',
              loss='binary_crossentropy',
              metrics=['accuracy'])

# Generate dummy data
import numpy as np
data = np.random.random((1000, 100))
labels = np.random.randint(2, size=(1000, 1))

# Train the model, iterating on the data in batches of 32 samples
model.fit(data, labels, epochs=10, batch_size=32)
like image 972
Alessandro Avatar asked Oct 20 '17 16:10

Alessandro


1 Answers

In the first and second part of the blog he explains how to use keras models with tensorflow.

Also I found this example of keras with distributed training.

And here is another with horovod.

like image 147
Julio Daniel Reyes Avatar answered Sep 22 '22 20:09

Julio Daniel Reyes