Skip to content

TypeError: Unable to serialize 64.0 to JSON. Unrecognized type <class 'tensorflow.python.framework.ops.EagerTensor'>. #61525

@cpodczerwinski

Description

@cpodczerwinski

Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

No

Source

source

TensorFlow version

2.13

Custom code

No

OS platform and distribution

Windows 11

Mobile device

No response

Python version

3.11.3

Bazel version

N/A

GCC/compiler version

N/A

CUDA/cuDNN version

Not using GPU

GPU model and memory

N/A

Current behavior?

I have been receiving this message when trying to save a variety of tensorflow models since version 2.11. I have reported it before.

It appears to be produced by the lack of an ability by tensorfow to serialize the model representations it maintains in memory.

TypeError: Unable to serialize 64.0 to JSON. Unrecognized type <class 'tensorflow.python.framework.ops.EagerTensor'>.

See the debugger output below for details

Can I change anything in my models to dodge this logic?
Is there another model saving function I can try?

Standalone code to reproduce the issue

Please email me for code.

Relevant log output

Traceback (most recent call last):
  File "D:\Craig\Python\Projects\CraigsPackages\koopman_operator_autoencoder_unit_tests.py", line 132, in <module>
    tf.keras.saving.save_model(model=autoencoder,  filepath='autoencoder_model', save_format="tf")
  File "C:\Users\Craig\AppData\Local\Programs\Python\Python311\Lib\site-packages\keras\src\saving\saving_api.py", line 149, in save_model
    return legacy_sm_saving_lib.save_model(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Craig\AppData\Local\Programs\Python\Python311\Lib\site-packages\keras\src\utils\traceback_utils.py", line 70, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "C:\Users\Craig\AppData\Local\Programs\Python\Python311\Lib\json\encoder.py", line 200, in encode
    chunks = self.iterencode(o, _one_shot=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Craig\AppData\Local\Programs\Python\Python311\Lib\json\encoder.py", line 258, in iterencode
    return _iterencode(o, 0)
           ^^^^^^^^^^^^^^^^^
TypeError: Unable to serialize 64.0 to JSON. Unrecognized type <class 'tensorflow.python.framework.ops.EagerTensor'>.

Metadata

Metadata

Labels

TF 2.13For issues related to Tensorflow 2.13staleThis label marks the issue/pr stale - to be closed automatically if no activitystat:awaiting responseStatus - Awaiting response from authorsubtype:cpu-intelTo track windows cpu issuestype:bugBug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions