# Troubleshooting

### Issues with loading or publishing Keras or Tensorflow models

![A common error that arises when there is a Keras or Tensorflow version mismatch](https://385940188-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MW6A6E0L1zra4m3voL_%2F-MeeQmHbx2SS3P-6MI8d%2F-MeeUF7gvbsxnG_XO-tQ%2FScreen%20Shot%202021-07-15%20at%2010.05.40%20AM.png?alt=media\&token=264031e9-1592-42bf-ac53-9b22c458ef3c)

There is a difference between the older, plain Keras package installed via `import keras`, and the currently maintained and up-to-date Keras package installed via `from tensorflow import keras`. Currently, the DLHub SDK (which Foundry uses under-the-hood to publish, pull, and run models and functions) uses whichever version of Keras you have installed.

Errors can arise when `tf.keras` is used in one part of the model pipeline, but plain `keras` is used in another.

If you have both versions of Keras installed (which can be the case in common container environments, such as Google Colab), DLHub will default to the plain Keras version, in case the user wants to use that with the newest version of Tensorflow. To override this functionality and use the Tensorflow Keras instead when publishing your model, pass the `force_tf_keras = True`option to `publish_model()`.

```python
# Assume our fitted model is '7-fi-1.hdf5'.
# Create the metadata for the model
import os

options_keras = {
            "title": "Bandgap-7-fidelity-MP-JARVIS-1",
            "short_name": "7-fi-1",
            "authors": ["Scientist, Awesome"],
            "servable": {
                "type": "keras",
                "model_path": "7-fi-1.hdf5",
                "custom_objects": {"softplus2": softplus2, 
                                   "MEGNetLayer": MEGNetLayer,
                                   "Set2Set": Set2Set},
                "force_tf_keras": True
            }
}
res = f.publish_model(options_keras)
```
