# No module named tf

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fno-module-named-tf%2F24173%3E%5C
**Category:** Spaces\
**Created:** [October 9, 2022, 7:32am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fno-module-named-tf%2F24173 "2022-10-09T07:32:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eskayML](https://avatars.discourse-cdn.com/v4/letter/e/eada6e/32.png) [@eskayML](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FeskayML)%5C
**Post date:** [October 9, 2022, 7:32am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fno-module-named-tf%2F24173%2F1 "2022-10-09T07:32:59Z")

</div>

Please I need help

My app [Here](https://huggingface.co/spaces/eskayML/cat-and-dog-classifier) is giving an error of no module named tf which I quite weird since I already installed tensorflow

---

<div class="post-metadata">

**Author:** ![nightfury](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nightfury/32/39775_2.png) [@nightfury](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnightfury)%5C
**Post date:** [October 10, 2022, 7:52am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fno-module-named-tf%2F24173%2F2 "2022-10-10T07:52:37Z")

</div>

ValueError: Unknown layer: Functional

```auto
File "/home/user/app/app.py", line 31, in <module>
    model = load_model('cat_and_dog_classifier.h5')File "/home/user/.local/lib/python3.8/site-packages/tensorflow/python/keras/saving/save.py", line 184, in load_model
    return hdf5_format.load_model_from_hdf5(filepath, custom_objects, compile)

```

the reason for this error is cause of use of different versions of Keras & TensorFlow… like in for training the model the version might have ‘2.3.0’ for Tensorflow & ‘2.4.3’ for Keras and now while accessing the saved model(.h5) are using another version of Keras & TensorFlow.

So for the solution it is best to re-trained model from scratch with upgraded versions or downgrades your TF&Keras to the same version as on which model is trained.

---

<div class="post-metadata">

**Author:** ![nightfury](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nightfury/32/39775_2.png) [@nightfury](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnightfury)%5C
**Post date:** [October 10, 2022, 7:56am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fno-module-named-tf%2F24173%2F3 "2022-10-10T07:56:34Z")

</div>

You may even use following code if you are using older TF and trying to unpack h5 file packed by newer TF

```auto
your_model = tf.keras.models.load_model(
    path_to_h5,
    custom_objects={'Functional':tf.keras.models.Model})

```

Follow below discussion for more details (hope it would be helpful):

> <https://stackoverflow.com/questions/63068639/valueerror-unknown-layer-functional>
