Table of Contents

tf.keras.models.load_model()

Function Definition: tf.keras.models.load_model(filepath = 'saved_model.h5', custom_objects = None, compile = True, options = None)

Parameters

NameTypeDescriptionExpected ValuesDefault Value
filepathstringOne of the following: String or pathlib (Path object, path to the saved model) OR h5py (File object from which to load the model),h5 model link'saved_model.h5'
custom_objectsstringOptional dictionary mapping names (strings) to custom classes or functions to be considered during deserialization.NoneNone
compilebooleanBoolean, whether to compile the model after loading.True or FalseTrue
optionsstringOptional - tf.saved_model.LoadOptions object that specifies options for loading from SavedModel.NoneNone

Description

The function loads a model saved via model.save().

The function returns a Keras model instance. If the original model was compiled and saved with the optimizer, then the returned model will be compiled. Otherwise, the model will be left uncompiled. In the case that an uncompiled model is returned, a warning is displayed if the compile the argument is set to True.

Import Libraries

####################imports####################
#do not change

import cv2
import numpy as np
import tensorflow as tf

#do not change
####################imports####################

Sample Use

model=tf.keras.models.load_model(
		'saved_model.h5', 
		custom_objects=None,
		compile=True, 
		options=None)

Example

There are no examples documented for this article.