InterviewsVector

Untraced Functions Warning during Model Saving

Quick answer

The 'Found untraced functions' warning when saving a Keras model is informational, not an error: TensorFlow could not trace some custom Python methods into the SavedModel graph, typically from custom layers or an RNN/LSTM cell. The model still saves and reloads correctly for inference. To silence it entirely, save in the modern .keras format instead of the legacy SavedModel/HDF5 format. If you must use SavedModel and rely on those exact methods after loading, pass them via custom_objects (or a get_config/from_config on your custom layer), or save the weights separately.

Short answer: Found untraced functions is an informational warning, not an error. TensorFlow couldn't trace some custom Python methods (often from an LSTM/RNN cell or a custom layer) into the SavedModel graph. Your model still saves and reloads for inference. The cleanest way to make the warning disappear is to save in the modern .keras format instead of legacy SavedModel/HDF5.

TensorFlow 'Found untraced functions' warning printed when saving a Keras model

You'll see something like this when calling model.save(...):

WARNING:absl:Found untraced functions such as lstm_cell_2_layer_call_fn,
lstm_cell_2_layer_call_and_return_conditional_losses while saving
(showing 2 of 2). These functions will not be directly callable after loading.

It means TensorFlow's autograph couldn't serialise a few internal Python functions — commonly the call methods of an RNN/LSTM cell or a custom layer — into the SavedModel graph. They "will not be directly callable after loading," but the standard forward pass (predict, evaluate, further fit) still works.

Why it happens

  1. Custom or wrapped layers / cells. A custom Layer, a subclassed model, or an RNN cell has methods autograph can't fully trace. This is by far the most common trigger — and the LSTM/GRU cells shown in the message are internal to Keras, so you often see it even without writing any custom code.
  2. Control flow autograph can't trace. Dynamic Python control flow (data-dependent if/loops) inside a layer's call may not serialise cleanly.
  3. Version skew. Saving under one TensorFlow version and loading under another can surface it.

The legacy SavedModel (a directory) and HDF5 (.h5) formats are what trigger this. The modern Keras v3 format serialises the architecture and weights without trying to trace those functions, so the warning goes away:

model.save("my_model.keras")          # note the .keras extension
 
# reload
import keras
model = keras.models.load_model("my_model.keras")

Fix 2 — save only the weights

If you keep the model-building code in your project, you don't need to serialise the graph at all — save the weights and rebuild:

model.save_weights("my_model.weights.h5")
 
# later
model = build_model()                 # same architecture in code
model.load_weights("my_model.weights.h5")

Fix 3 — if you use SavedModel, register your custom objects

If you must keep the SavedModel format and you rely on a custom layer's methods after loading, make the layer reconstructible with get_config/from_config and pass it via custom_objects:

model = tf.keras.models.load_model(
    "saved_model_dir",
    custom_objects={"MyCustomLayer": MyCustomLayer},
)

When you can just ignore it

If you only need the model for inference/prediction and you're not calling those internal functions directly, the warning is safe to ignore — the SavedModel round-trips correctly. Switching to .keras is worth it mainly to keep your logs clean and avoid the format's other legacy sharp edges.

Sources

Key takeaways

  • •The 'Found untraced functions' message is informational, not an error - the model still saves and reloads for inference.
  • •It means TensorFlow could not trace some custom Python methods (often from a custom layer or an LSTM/RNN cell) into the SavedModel graph.
  • •A TensorFlow version mismatch between saving and loading can also trigger it.
  • •If you depend on those exact methods after loading, supply them via custom_objects or save the weights separately.

Frequently asked questions

Is 'Found untraced functions' an error?

No. It is a warning that some custom methods were not traced into the SavedModel graph. The model still saves and loads correctly for standard inference.

Will my model still work after this warning?

Yes for normal inference and prediction. Only custom methods that were not traced may be unavailable after loading, in which case pass them through custom_objects.

What causes untraced functions?

Custom layers or cells, control-flow that autograph cannot trace, or a version mismatch between the TensorFlow used to save and to load the model.

By Mohammad Wasi

Software Engineering Leader & Technical Author · Updated September 9, 2026


Related Posts