keras.models.load_model ValueError: Unknown layer: Functional

2,189 views
Skip to first unread message

GO

unread,
Aug 7, 2020, 7:22:33 AM8/7/20
to TensorFlow Developers
Hello,

I'm trying to load my model on an EC2 environment but i have the following issue:

ValueError: Unknown layer: Functional

i'm using the following command in python:

from tensorflow import keras
model = keras.models.load_model('/home/ubuntu/full_model.h5')

On Google colab it works perfectly but not on EC2.

Does anyone have this issue? I don't find anything on other forums.

muhammad harris

unread,
Aug 7, 2020, 7:26:55 AM8/7/20
to GO, TensorFlow Developers
Hi. I think the model was trained on the recent tensorflow 2.3 version that names all nodes created with functional api with a 'functional' prefix. You may want to upgrade your EC2 tendorflow to 2.3 then try loading the model.

--
You received this message because you are subscribed to the Google Groups "TensorFlow Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/developers/1309874b-7dcb-4cbd-88c1-d526cd6d8d79o%40tensorflow.org.

Aditya Srivastava

unread,
Aug 7, 2020, 7:29:28 AM8/7/20
to GO, TensorFlow Developers
Did you check the versions? 
Python, Tensorflow, try to keep them the same.

I'd suggest making a venv
Make a requirements.txt from Colab and use it to install dependencies on EC2's venv.

Ilya Persky

unread,
Aug 7, 2020, 8:21:33 AM8/7/20
to Aditya Srivastava, GO, TensorFlow Developers

GO

unread,
Aug 7, 2020, 5:09:50 PM8/7/20
to TensorFlow Developers
Thank you all! Yes I was using an old version of tf... :)

Francois Chollet

unread,
Aug 7, 2020, 5:28:12 PM8/7/20
to GO, TensorFlow Developers
This appears to be a forward compatibility issue: you cannot load a model saved with TF 2.2+ using an earlier version of TF. In general, forward compatibility is never guaranteed, but backwards compatibility is.

However you should be able to load earlier models using a more recent TF version.

The fix here should be for you to upgrade the TF version of the VM where you load the model to match or exceed the version number of the VM where you saved the model. (i.e. make sure to use TF 2.2 or TF 2.3).

Please let us know if that works for you.

Best,

Francois

--
You received this message because you are subscribed to the Google Groups "TensorFlow Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@tensorflow.org.

GO

unread,
Aug 8, 2020, 7:34:07 AM8/8/20
to TensorFlow Developers
Hello Francois,

Yes thank you for the precision. Now it works perfectly following the upgrade of tf.

Actually, I was not using a good instance of EC2... I needed to choose another one for ML.

Thanks everyone again :)

Le vendredi 7 août 2020 13:22:33 UTC+2, GO a écrit :
Reply all
Reply to author
Forward
0 new messages