cerndb / dist-keras

Distributed Deep Learning, with a focus on distributed training, using Keras and Apache Spark.
http://joerihermans.com/work/distributed-keras/
GNU General Public License v3.0
623 stars 169 forks source link

Is it possible to implement dist-keras and run in local machine for this Keras Model #72

Open mohaimenz opened 6 years ago

mohaimenz commented 6 years ago

Hi @JoeriHermans, I am reading the documentation of this repository. My experimental setup runs on Theano for accuracy reproducibility. Now, I need to train my model in distributed fashion on multiple nodes. I tried ELEPHAS as it asks for least amount of change and it also runs on Theano. However, I failed to run my experiment with that. Now, I am looking at your API and it seems that I will have to rewrite my whole experiment. I am putting my model here. It would be great to have your suggestion in this regard. I also would like to know if it is possible to run the dist-keras implementation in my local machine. My local machine has 8 cores and one 4GB NVIDIA GPU.

model = Sequential();
model.add(Dropout(0.2, input_shape=(122,)));
model.add(Dense(150, kernel_initializer='normal', activation='relu', kernel_constraint=maxnorm(3)));
model.add(Dropout(0.5));
model.add(Dense(120, kernel_initializer='normal', activation='relu', kernel_constraint=maxnorm(3)));
model.add(Dropout(0.5));
model.add(Dense(50, kernel_initializer='normal', activation='relu', kernel_constraint=maxnorm(3)));
model.add(Dropout(0.5));
model.add(Dense(2, kernel_initializer='normal', activation='sigmoid'));

sgd = SGD(lr=0.1, momentum=0.9, decay=1e-6, nesterov=True);
model.compile(loss='mean_squared_error', optimizer=sgd, metrics=['accuracy']);
###trainX, trainY, testX, testY are all numpy variables where categorical values are discretized by one-hot ###encoding and normalized using z-score normalization using sklearn.preprocessing
model.fit(trainX, trainY, epochs=50, batch_size=32, shuffle=True, verbose=1);
testYPredicted = model.predict(testX, batch_size=32);
anishsharma commented 6 years ago

You can run it in local but use SingleTrainer train() instead model.fit() for that purpose. He has various examples you can follow to get the idea.