inception-v3
model checkpoint
retrained model
machine learning
tensorflow

How do I get the 'checkpoint' of a retrained inception-v3 model?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

A “checkpoint” is the saved state of your model weights, usually along with optimizer state if you want to resume training. For a retrained Inception-v3 model, getting the checkpoint depends on how you trained it. In modern TensorFlow or Keras, you typically create checkpoints explicitly with ModelCheckpoint or tf.train.Checkpoint. In older TensorFlow transfer-learning scripts, the retraining pipeline may have produced graph files and label files separately, which is a different artifact from a true checkpoint.

Know Which Artifact You Actually Need

People often mix up three different outputs:

  • checkpoint files for resuming training
  • saved models for deployment
  • frozen graphs or exported inference graphs

If you want to continue training later, you want a checkpoint. If you want to serve or ship the model, you may want a saved model instead. The correct answer starts with that distinction.

Keras Checkpoint Example for Retrained Inception-v3

A modern transfer-learning workflow might look like this:

python
1import tensorflow as tf
2
3base_model = tf.keras.applications.InceptionV3(
4    include_top=False,
5    weights="imagenet",
6    input_shape=(299, 299, 3)
7)
8base_model.trainable = False
9
10model = tf.keras.Sequential([
11    base_model,
12    tf.keras.layers.GlobalAveragePooling2D(),
13    tf.keras.layers.Dense(1, activation="sigmoid")
14])
15
16model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"])

To save checkpoints during training:

python
1checkpoint_cb = tf.keras.callbacks.ModelCheckpoint(
2    filepath="checkpoints/inceptionv3-{epoch:02d}.weights.h5",
3    save_weights_only=True,
4    save_best_only=False
5)
6
7model.fit(train_ds, validation_data=val_ds, epochs=5, callbacks=[checkpoint_cb])

Now the checkpoint files are written into the checkpoints directory during training.

Use tf.train.Checkpoint for Lower-Level Control

If you want TensorFlow-style checkpoint objects rather than callback-based weight files, use tf.train.Checkpoint.

python
1import tensorflow as tf
2
3checkpoint = tf.train.Checkpoint(model=model)
4manager = tf.train.CheckpointManager(checkpoint, "./tf_checkpoints", max_to_keep=3)
5
6model.fit(train_ds, epochs=1)
7manager.save()

This creates TensorFlow checkpoint artifacts you can restore later:

python
checkpoint.restore(manager.latest_checkpoint)

This is closer to the traditional TensorFlow meaning of “checkpoint.”

If You Used an Older Retraining Script

Older TensorFlow image retraining examples, especially around Inception-v3 transfer learning, often produced outputs such as:

  • 'output_graph.pb'
  • 'output_labels.txt'

Those are useful for inference, but they are not the same thing as a checkpoint for resuming training. If the training script did not explicitly save checkpoint state, you may not have a resumable checkpoint artifact even though you do have an exported graph.

So if you are asking “where is the checkpoint,” first inspect what the training script actually saves.

Save the Best Model During Fine-Tuning

When you fine-tune the unfrozen Inception layers, it is often useful to save the best validation checkpoint rather than every epoch.

python
1checkpoint_cb = tf.keras.callbacks.ModelCheckpoint(
2    filepath="best_inception.weights.h5",
3    monitor="val_accuracy",
4    mode="max",
5    save_best_only=True,
6    save_weights_only=True
7)

This produces a reusable weight snapshot for the best observed model during retraining.

Loading the Checkpoint Back

To restore weights into the same architecture:

python
model.load_weights("best_inception.weights.h5")

The architecture must match the checkpoint. That means the model definition used at restore time must be consistent with the one used during training.

This is a common source of confusion when transfer-learning code evolves between training and loading.

Common Pitfalls

The most common mistake is calling an exported .pb graph a “checkpoint.” They are different artifact types and serve different purposes.

Another mistake is training a retrained Inception-v3 model without adding any checkpoint callback or checkpoint manager, then expecting a resumable checkpoint to appear automatically.

Developers also forget that restoring weights requires the same model architecture shape and layer naming assumptions used when the checkpoint was written.

Summary

  • A checkpoint is a saved training state, usually weights and sometimes optimizer state.
  • In modern Keras, use ModelCheckpoint or tf.train.Checkpoint to create it explicitly.
  • Older retraining scripts may export graphs for inference without creating resumable checkpoints.
  • Decide whether you need a training checkpoint or a deployment artifact before choosing the save format.
  • To restore a checkpoint successfully, rebuild the same model architecture and then load the saved state.

Course illustration
Course illustration

All Rights Reserved.