tensorflow / tensorflow/recommenders
TypeError: Unable to serialize b'1' to JSON. Unrecognized type <class 'bytes'>.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2k
- Forks
- 300
- PR merge metrics
- No merged PRs in 30d
Description
I got this error: TypeError: Unable to serialize b'1' to JSON. Unrecognized type <class 'bytes'>. when I was trying to save my retrieval model and following the guide from the official tensorflow document.
Here's my code:
scannIndex = tfrs.layers.factorized_top_k.ScaNN(baseRetrieval.userModel)
scannIndex.index_from_dataset(tf.data.Dataset.zip((movies.batch(512), movies.batch(512).map(model.movie_model))))
scannIndexPath = "drive/MyDrive/TensorflowModels/"Retrieval""
keras.models.save_model(scannIndex, scannIndexPath)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the ScaNN construction, index_from_dataset call, and keras.models.save_model snippet in the report. Inspect model serialization around the ScaNN entry point and identify why bytes reach JSON serialization; done means the retrieval model saves without the reported TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, tensorflow
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100