SIMEXP / fmri_predict

predicting fmri activaties from connectome
15 stars 11 forks source link

run model using multi-gpus in keras #6

Open zhangyu2ustc opened 5 years ago

zhangyu2ustc commented 5 years ago

In Keras, it is simple to using multi-gpu instead of one.

# make the model parallel
model = multi_gpu_model(model, gpus=G)

as instructed in the following website: https://www.pyimagesearch.com/2017/10/30/how-to-multi-gpu-training-with-keras-python-and-deep-learning/

zhangyu2ustc commented 5 years ago

New models: HCP_task_fmri_cnn_tensorpack_changesize_bk.py

zhangyu2ustc commented 5 years ago

Convert the model from multi-gpu to only CPU version:

###put the model on CPU only
with tf.device("/cpu:0"):
    if Flag_CNN_Model == '2d':
        print('\nTraining the model using 2d-CNN with learning-rate: %s \n' % str(learning_rate))
        model_test = build_cnn_model_test(img_shape, nb_class)
    elif Flag_CNN_Model == '3d':
        print('\nTraining the model using 3d-CNN with learning-rate: %s \n' % str(learning_rate))
        model_test = build_cnn3d_model_test(img_shape, nb_class)