tensorflow / recommenders

TensorFlow Recommenders is a library for building recommender system models using TensorFlow.
Apache License 2.0
1.82k stars 273 forks source link

tfrs.Model.summary() function got error #253

Open JasonCaoJR opened 3 years ago

JasonCaoJR commented 3 years ago

If follow the quick start guide, https://www.tensorflow.org/recommenders/examples/quickstart

Define class MovieLensModel(tfrs.Model): model = MovieLensModel(user_model, movie_model, task)

after compile and fit the model, if try to call model.summary() function, it will generate error.

maciejkula commented 3 years ago

When reporting an issue it's customary to include the actual error message - this really helps in figuring out what's gone wrong.

JasonCaoJR commented 3 years ago

Traceback (most recent call last): File "D:/TechBuilder/TensorFlow/Dev202103/tfrs/tfrs1.py", line 214, in rs1() File "D:/TechBuilder/TensorFlow/Dev202103/tfrs/tfrs1.py", line 185, in rs1 print("model summary", model.summary()) File "D:\Apps\Python\lib\site-packages\tensorflow\python\keras\engine\training.py", line 2376, in summary raise ValueError('This model has not yet been built. ' ValueError: This model has not yet been built. Build the model first by calling build() or calling fit() with some data, or specify an input_shape argument in the first layer(s) for automatic build.

Process finished with exit code 1

Flipper-afk commented 3 years ago

You can try model.user_model.summary() or model.movie_model.summary(). It should then, output the parameters of each model. Hope that helps in a nutshell

TimSchmeier commented 3 years ago

you might need to run a batch of data through before calling summary()