Keras: Load checkpoint weights HDF5 generated by multiple GPUs

前端 未结 2 419
长情又很酷
长情又很酷 2021-01-19 23:16

Checkpoint snippet:

checkpointer = ModelCheckpoint(filepath=os.path.join(savedir, \"mid/weights.{epoch:02d}.hd5\"), monitor=\'val_loss\', verbose=1, save_bes         


        
2条回答
  •  旧巷少年郎
    2021-01-20 00:11

    You can load your model on a single GPU like this:

    from keras.models import load_model
    
    multi_gpus_model = load_model('mid')
    origin_model = multi_gpus_model.layers[-2]  # you can use multi_gpus_model.summary() to see the layer of the original model
    origin_model.save_weights('single_gpu_model.hdf5')
    

    'single_gpu_model.hdf5' is the file that you can load to the single GPU machine model.

提交回复
热议问题