from tensorflow.keras.models import Sequential model = Sequential([...]) # build your model here model.load_weights("saved_weights.h5") # load weights from saved file
from tensorflow.keras.models import Model from tensorflow.keras.layers import Input, Dense inputs = Input(shape=(10,)) x = Dense(64, activation="relu")(inputs) outputs = Dense(1, activation="sigmoid")(x) model = Model(inputs=inputs, outputs=outputs) model.compile(...) model.load_weights("saved_weights.h5")This example shows how to load weights into a Keras functional model with two Dense layers. The model is first built using the functional API, then compiled, and then the weights are loaded from a file called "saved_weights.h5". Package library: TensorFlow's Keras Models package