aten_model.py
def load_weights(self, filepath, by_name=False, exclude=None):
        """Modified version of the correspoding Keras function with
        the addition of multi-GPU support and the ability to exclude
        some layers from loading.
        exlude: list of layer names to excluce
        """
        import h5py
        from keras.engine import topology

        if exclude:
            by_name = True

        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']

        # In multi-GPU training, we wrap the model. Get layers
        # of the inner model because they have the weights.
        keras_model = self.keras_model
        layers = keras_model.inner_model.layers if hasattr(keras_model, "inner_model")\
            else keras_model.layers

        # # exclude some layers
        if exclude:
            layers = filter(lambda l: exclude.match(l.name)==None, layers)

        # layers_name = [l.name for l in layers]
        print("load model", filepath)

        if by_name:
            topology.load_weights_from_hdf5_group_by_name(f, layers)
        else:
            topology.load_weights_from_hdf5_group(f, layers)
        if hasattr(f, 'close'):
            f.close()

        # Update the log directory
        self.set_log_dir(filepath)
Modified version of the correspoding Keras function with
        the addition of multi-GPU support and the ability to exclude
        some layers from loading.
        exlude: list of layer names to excluce
        
Modified version of the correspoding Keras function with
the addition of multi-GPU support and the ability to exclude
some layers from loading.
exlude: list of layer names to excluce
Modified version of the correspoding Keras function with the addition of multi - GPU support and the ability to exclude some layers from loading . exlude : list of layer names to excluce
def load_weights(self, filepath, by_name=False, exclude=None):
        import h5py
        from keras.engine import topology
        if exclude:
            by_name = True
        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']
        keras_model = self.keras_model
        layers = keras_model.inner_model.layers if hasattr(keras_model, "inner_model")\
            else keras_model.layers
        if exclude:
            layers = filter(lambda l: exclude.match(l.name)==None, layers)
        print("load model", filepath)
        if by_name:
            topology.load_weights_from_hdf5_group_by_name(f, layers)
        else:
            topology.load_weights_from_hdf5_group(f, layers)
        if hasattr(f, 'close'):
            f.close()
        self.set_log_dir(filepath)
def load_weights ( self , filepath , by_name = False , exclude = None ) : import h5py from keras . engine import topology if exclude : by_name = True 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' ] keras_model = self . keras_model layers = keras_model . inner_model . layers if hasattr ( keras_model , "inner_model" ) else keras_model . layers if exclude : layers = filter ( lambda l : exclude . match ( l . name ) == None , layers ) print ( "load model" , filepath ) if by_name : topology . load_weights_from_hdf5_group_by_name ( f , layers ) else : topology . load_weights_from_hdf5_group ( f , layers ) if hasattr ( f , 'close' ) : f . close ( ) self . set_log_dir ( filepath )
Modified version of the correspoding Keras function with
the addition of multi-GPU support and the ability to exclude
some layers from loading.
Modified version of the correspoding Keras function with the addition of multi - GPU support and the ability to exclude some layers from loading .
"""Modified version of the correspoding Keras function with
        the addition of multi-GPU support and the ability to exclude
        some layers from loading.
        exlude: list of layer names to excluce
        """ # In multi-GPU training, we wrap the model. Get layers # of the inner model because they have the weights. # # exclude some layers # layers_name = [l.name for l in layers] # Update the log directory
self
filepath
by_name
exclude