'Loads all layer weights from a HDF5 save file.
If `by_name` is False (default) weights are loaded
based on the network\'s topology, meaning the architecture
should be the same as when the weights were saved.
Note that layers that don\'t have weights are not taken
into account in the topological ordering, so adding or
removing layers is fine as long as they don\'t have weights.
If `by_name` is True, weights are loaded into layers
only if they share the same name. This is useful
for fine-tuning or transfer-learning models where
some of the layers have changed.
# Arguments
filepath: String, path to the weights file to load.
by_name: Boolean, whether to load weights by name
or by topological order.
# Raises
ImportError: If h5py is not available.'

def load_weights(self, filepath, by_name=False):

    if (h5py is None):
        raise ImportError('`load_weights`    requires    h5py.')
    f = h5py.File(filepath, mode='r')
    if (('layer_names' not in f.attrs) and ('model_weights' in f)):
        f = f['model_weights']
    if by_name:
        load_weights_from_hdf5_group_by_name(f, self.layers)
    else:
        load_weights_from_hdf5_group(f, self.layers)
    if hasattr(f, 'close'):
        f.close()
