Valueerror: unexpected result of `train_function` (empty logs). please use `model.compile(…, run_eagerly=true)`, or `tf.config.run_functions_eagerly(true)` for more information of where went wrong, or file a issue/bug to `tf.keras`.

Error Details: ValueError: Unexpected result of `train_function` (empty logs).

Solution: To get more information about what went wrong, you can enable eager execution using either `model.compile(…, run_eagerly=True)` or `tf.config.run_functions_eagerly(True)`.

Enabling eager execution allows TensorFlow to execute operations immediately as they are called, which can help in debugging and catching errors.

Here are a few examples to illustrate the usage:

  1. Enable eager execution using `model.compile(…, run_eagerly=True)`:
  2. import tensorflow as tf
    
    model = tf.keras.models.Sequential(...)
    model.compile(optimizer='adam', loss='mse', run_eagerly=True)
    model.fit(...)
        

    In this example, we set the `run_eagerly` parameter of `model.compile()` to `True`, enabling eager execution for training. This can help in capturing the detailed logs and debugging the issue.

  3. Enable eager execution using `tf.config.run_functions_eagerly(True)`:
  4. import tensorflow as tf
    
    tf.config.run_functions_eagerly(True)
    
    model = tf.keras.models.Sequential(...)
    model.compile(optimizer='adam', loss='mse')
    model.fit(...)
        

    In this example, we invoke `tf.config.run_functions_eagerly(True)` before creating the model. This enables eager execution globally for all TensorFlow functions, including the model training process.

If enabling eager execution doesn’t provide enough information or solve the issue, you may consider filing an issue/bug report to `tf.keras` for further assistance.

Similar post

Leave a comment