Keras: Load checkpoint weights HDF5 generated by multiple GPUs
<p>Checkpoint snippet:</p>

<pre><code>checkpointer = ModelCheckpoint(filepath=os.path.join(savedir, "mid/weights.{epoch:02d}.hd5"), monitor='val_loss', verbose=1, save_best_only=False, save_weights_only=False)
hist = model.fit_generator(
    gen.generate(batch_size = batch_size, nb_classes=nb_classes), samples_per_epoch=593920, nb_epoch=nb_epoch, verbose=1, callbacks=[checkpointer], validation_data = gen.vld_generate(VLD_PATH, batch_size = 64, nb_classes=nb_classes), nb_val_samples=10000
)
</code></pre>

<p>I trained my model on a multiple GPU host which dumps <code>mid</code> files in HDF5 format. When I loaded them on a single GPU machine with <code>keras.load_weights('mid')</code>, an error was raised:</p>

<pre><code>Using TensorFlow backend.
Traceback (most recent call last):
  File "server.py", line 171, in &lt;module&gt;
    model = load_model_and_weights('zhch.yml', '7_weights.52.hd5')
  File "server.py", line 16, in load_model_and_weights
    model.load_weights(os.path.join('model', weights_name))
  File "/home/lz/code/ProjectGo/meta/project/libpolicy-server/.virtualenv/lib/python3.5/site-packages/keras/engine/topology.py", line 2701, in load_weights
    self.load_weights_from_hdf5_group(f)
  File "/home/lz/code/ProjectGo/meta/project/libpolicy-server/.virtualenv/lib/python3.5/site-packages/keras/engine/topology.py", line 2753, in load_weights_from_hdf5_group
    str(len(flattened_layers)) + ' layers.')
ValueError: You are trying to load a weight file containing 1 layers into a model with 21 layers.
</code></pre>

<p>Is there any way to load checkpoint weights generated by multiple GPUs on a single GPU machine? It seems that no issue of Keras discussed this problem thus any help would be appreciated.</p>