2017-10-20 224 views
3

我有兩個不同的機器上安裝兩顆GPU。我想建立一個集羣,讓我通過使用兩個GPU一起學習Keras模型。通過學習Keras模型中使用分佈式Tensorflow

Keras blog顯示兩段代碼分佈式培訓部分和鏈接官方Tensorflow documentation

我的問題是,我不知道如何學習我的模型,寫在Keras,用實際描述Tensorflow對象的過程Tensorflow文檔。

例如,我應該怎麼做,如果我想多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) 

回答

1

在博客的第一部分和第二部分,他解釋瞭如何使用具有張量流的keras模型。

而且我發現keras的這個例子與distributed training

這裏是另一個與horovod