Saving and Loading Recommenders Models

I have written a model using the sequential retrieval example guide and I am attempting to save and load the model to test its portability. In the example, the tfrs.Model is sub classed and the init and the compute_loss functions are overridden. I am running into issues attempting to save the model:

  1. The high level Model.Save() fails because the ‘input shape is not available or because the forward pass of the model is not defined.’
  2. The same applies to tf.keras.Models.save_model() (which I suppose makes sense as I understand them to be equivalent).
  3. The…) does save something, however when I load the model I get a ‘TypeError: ‘_UserObject’ object is not callable’ The model does not appear to be usable.

I would very much appreciate an direction on how to fix this as I have hit a wall.


I’ve figured out the issue, but I wanted to post here for future searches. I had two issues:

  1. I was creating and running on my local Anaconda3 instance, so moved the model creation to google colab and ran it there.
  2. I was also not calling the model before saving it, like so: _ = index(np.array(["42"]))

Once I called the model to save the input shape, was able to save and then reload using the…)

1 Like