tensorflow / tensorflow/recommenders

TypeError: Unable to serialize b'1' to JSON. Unrecognized type <class 'bytes'>.

Open
#429 4 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.