recommenders
recommenders copied to clipboard
TypeError: Unable to serialize b'1' to JSON. Unrecognized type <class 'bytes'>.
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)
Could you try using tf.saved_model.save
instead of keras.models.save_model
?
@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
?
@maciejkula I also encountered the same error. I would like to know why. Is there a fundamental bug lurking in tensorflow?
Same error here to save the movielens model defined as the tutorial.