示例#1
0
def load_h5(cellar_path):
    """ return hdf5 model loaded from cellar path """
    if not cellar_path[0] == '/':
        cellar_path = '/'+cellar+path

    config = _configs.Config()
    return _load_model(config.resolve_paths(cellar_path))
示例#2
0
    def __init__(self):

        _common_model.__init__(self)

        # Define sample directory
        self.sample_dir = _os.path.join(self.sample_dir, 'rotation')

        # Load compiled model
        self._mod = _load_model('rot_mod.h5')

        # Load category (i.e. 'class') names
        self._class_names = _np.load('rot_class_names.npy')
        self.class_name_dict = dict([[v, k] for k, v in self._class_names])
def load_uncompiled_model(filepath):
    '''
    Loads the specified Keras model without compiling it.

    NB Model can be either compiled or uncompiled.

    Arguments:
        filepath - the filepath of the model

    Returns:
        model - a keras.models.Sequential object

    '''
    return _load_model(filepath, compile=False)
def load_model(filepath):
    '''
    Loads and compiles the specified Keras model.

    NB Model must have been pre-compiled with an optimiser

    Arguments:
        filepath - the filepath of the model

    Returns:
        model - a keras.models.Sequential object

    '''
    return _load_model(filepath, custom_objects=CUSTOM_OBJ_DICT)
示例#5
0
def load_model(modelf, **kwargs):
    from keras.models import clone_model as _clone_model, Sequential, \
        load_model as _load_model
    # import these since keras doesn't load them by default
    #from AdamW import AdamW
    #from SGDW import SGDW
    custom_objects = kwargs.pop('custom_objects', {})
    #custom_objects['AdamW'] = AdamW
    #custom_objects['SGDW'] = SGDW

    flatten = kwargs.pop('flatten', False)
    model = _load_model(modelf, custom_objects=custom_objects, **kwargs)
    if flatten and model.layers[0].name.startswith('sequential_'):
        _model = _clone_model(model.layers[0])
        for layer in model.layers[1:]:
            _model.add(layer)
        model = _model
    return model
示例#6
0
def load_model(model):
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        return _load_model(model)
示例#7
0
def load_model(file_h5):
    """Load model from file."""
    model = _load_model(file_h5)
    # FIXME see keras#6462
    model._make_predict_function()
    return model
示例#8
0
def load_model() -> Model:
    return _load_model(resource_filename(
        Requirement.parse("ca2spike"),
        "ca2spike/data/model_{}.h5".format(K.backend())),
                       custom_objects={"_pearson_corr": pearson_corr})
示例#9
0
def load_model() -> Model:
    return _load_model(str(rotation_model_config.MODEL_PATH))