-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Notebook 05: TypeError: Unable to serialize [2.0897 2.1129 2.1082] to JSON. Unrecognized type <class 'tensorflow.python.framework.ops.EagerTensor'>
(fix inside)
#553
Comments
TypeError: Unable to serialize [2.0897 2.1129 2.1082] to JSON. Unrecognized type <class 'tensorflow.python.framework.ops.EagerTensor'>
TypeError: Unable to serialize [2.0897 2.1129 2.1082] to JSON. Unrecognized type <class 'tensorflow.python.framework.ops.EagerTensor'>
(fix inside)
There is a way to edit the efficientnet.py file directly to correct this issue, letting us use efficientnet with tf 2.10 and above. That being out of the way, here are the steps:
that's basically it! If you managed to do these steps correctly, you will now have gotten rid of this annoying error! One extra info for Docker containers - if you work within the Docker container, you will likely have to install an editor first using apt-get install vim or apt-get install nano or whatever else you want to use. thanks to Mik0ri in Discord for bringing this to my attention! Source: |
There is a bug in TensorFlow versions 2.10, 2.11 and 2.11. Here is the tensorflow issue link with the same problem. |
Hi all, After much troubleshooting, I've found the best fix for You can see a full write-up of the fix here: #575 |
Update for August 2023
If you're using TensorFlow 2.10+, I've found the best fix for
tf.keras.applications.efficient.EfficientNetB0
problems is to simply upgrade totf.keras.applications.efficientnet_v2.EfficientNetV2B0
.You can see a full write-up of the fix here: #575
In short:
New:
Old:
If for some reason, you'd like to keep using
tf.keras.applications.efficientnet.X
models, keep reading below.If you're trying to save
tf.keras.applications.efficientnet.X
models in TensorFlow 2.10+, you may see the following issue:According to the Keras GitHub issues thread (see: keras-team/tf-keras#383) this is an issue with one of the rescaling layers.
There are several solutions in the linked thread above, however, a consistent fix I've found (as of May 2023) is to use TensorFlow 2.9.0:
If you're using Google Colab, you can run the code at the top of your notebook and run the rest of Notebook 05: https://github.com/mrdbourke/tensorflow-deep-learning/blob/main/05_transfer_learning_in_tensorflow_part_2_fine_tuning.ipynb without errors.
I tried to run this gist which claims fixes in
tf-nightly(2.13.0-dev20230409)
, however, I found that the fix didn't work in a later versiontf-nightly(2.14.0-dev20230520)
.Hopefully it gets fixed in future versions of TensorFlow.
See a thread about possible fixes here: #544
Another alternative if you're using a later version of TensorFlow (2.10+) may be to try another model from
tf.keras.applications.efficientnet_v2
.The text was updated successfully, but these errors were encountered: