recommenders icon indicating copy to clipboard operation
recommenders copied to clipboard

model.summary() report errors

Open silver1886 opened this issue 3 years ago • 1 comments
trafficstars

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.

silver1886 avatar Aug 31 '22 17:08 silver1886

@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.

ydennisy avatar Sep 01 '22 09:09 ydennisy