2017-10-20 215 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