Speichern z.B mit
layer_names = [layer.name for layer in model.layers]
callbacks = []
for layer_name in layer_names:
layer_checkpoint_callback = tf.keras.callbacks.ModelCheckpoint(
filepath=f"{layer_name}_weights.h5",
save_weights_only=True,
save_freq='epoch'
)
callbacks.append(layer_checkpoint_callback)
model.fit(..., callbacks=callbacks)
und laden mit
model = create_model(...)
layer_names = [layer.name for layer in model.layers]
for layer_name in layer_names:
if os.path.exists(f"{layer_name}_weights.h5"):
layer_model = create_model(...)
layer_model.load_weights(f"{layer_name}_weights.h5")
model.get_layer(layer_name).set_weights(layer_model.get_layer(layer_name).get_weights())
https://keras.io/api/layers/