tensorflow / tensorflow/recommenders

Not able to save model for the quickstart example

Open
#276 5 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

Here is the quickstart example: https://www.tensorflow.org/recommenders/examples/quickstart

It works fine, but I am not able to save the model by model.save('my_model') at the end. It throws exception:

WARNING:tensorflow:Skipping full serialization of Keras layer <__main__.MovieLensModel object at 0x7f727eec7690>, because it is not built.
WARNING:tensorflow:Skipping full serialization of Keras layer <__main__.MovieLensModel object at 0x7f727eec7690>, because it is not built.
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-8-5a8adf13c269> in <module>()
----> 1 model.save("my_model")

3 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/saving/saving_utils.py in raise_model_input_error(model)
     96       'set. Usually, input shapes are automatically determined from calling'
     97       ' `.fit()` or `.predict()`. To manually set the shapes, call '
---> 98       '`model.build(input_shape)`.'.format(model))
     99 
    100 

ValueError: Model <__main__.MovieLensModel object at 0x7f727eec7690> cannot be saved because the input shapes have not been set. Usually, input shapes are automatically determined from calling `.fit()` or `.predict()`. To manually set the shapes, call `model.build(input_shape)`.

This is reproducible. See https://colab.research.google.com/drive/1yktbZXJUb__VAqWvrCH1h0xgJt3XR7Wc?usp=sharing

How can I fix this?

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 with the TensorFlow Recommenders quickstart example and reproduce the failure in the linked Colab notebook. Inspect the MovieLensModel call path around model.save('my_model') and the input-shape warning. Done means the quickstart model saves successfully without the reported ValueError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.