tensorflow / recommenders

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

model.summary() report errors #540

Open silver1886 opened 2 years ago

silver1886 commented 2 years ago

Hi thanks for writing this amazing package!

I'm trying to follow the tutorial codes for item retrieval: https://www.tensorflow.org/recommenders/examples/basic_retrieval After fitting the model, I'm trying to see the detail information of the model, so I write model.summary(), however it shows

ValueError Traceback (most recent call last)

in ----> 1 model.summary() /usr/local/lib/python3.8/site-packages/keras/engine/training.py in summary(self, line_length, positions, print_fn, expand_nested, show_trainable) 2867 """ 2868 if not self.built: -> 2869 raise ValueError( 2870 'This model has not yet been built. ' 2871 'Build the model first by calling `build()` or by calling ' ValueError: This model has not yet been built. Build the model first by calling `build()` or by calling the model on a batch of data. Though the model has been trained successfully, I'm wondering if it is a bug or the model type does not support model.summary()? Thanks.
ydennisy commented 2 years ago

@silver1886 you need to call model.build() or normally it works best by calling model.predict(ds.take(1)) so you need to predict on a single batch of your data - this allows the model to learn the input sizes and you will then be able to generate a summary.

If this does not work I suggest posting your full model code.