recommenders icon indicating copy to clipboard operation
recommenders copied to clipboard

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

Open RAHEYO opened this issue 3 years ago • 4 comments

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)

RAHEYO avatar Jan 04 '22 07:01 RAHEYO

Could you try using tf.saved_model.save instead of keras.models.save_model?

maciejkula avatar Jan 11 '22 18:01 maciejkula

@maciejkula Would you mind explaining why tf.saved_model.save behaves differently from keras.models.save_model? Does the error that @RAHEYO got reveal a bug in keras.models.save_model?

rlcauvin avatar Mar 22 '22 13:03 rlcauvin

@maciejkula I also encountered the same error. I would like to know why. Is there a fundamental bug lurking in tensorflow?

fuchami avatar Apr 22 '22 08:04 fuchami

Same error here to save the movielens model defined as the tutorial.

byzhang avatar Sep 07 '22 05:09 byzhang