From: Francois Chollet Date: Thu, 24 May 2018 21:58:15 +0000 (-0700) Subject: Raise ValueError when calling model.summary() before it is built X-Git-Tag: upstream/v1.9.0_rc1~38^2~4^2~92 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b42bc6ee8448496f11e03e5c9a881d3655caf945;p=platform%2Fupstream%2Ftensorflow.git Raise ValueError when calling model.summary() before it is built PiperOrigin-RevId: 197959372 --- diff --git a/tensorflow/python/keras/engine/network.py b/tensorflow/python/keras/engine/network.py index 6e818ec..6db4147 100644 --- a/tensorflow/python/keras/engine/network.py +++ b/tensorflow/python/keras/engine/network.py @@ -1428,7 +1428,15 @@ class Network(base_layer.Layer): It will be called on each line of the summary. You can set it to a custom function in order to capture the string summary. + + Raises: + ValueError: if `summary()` is called before the model is built. """ + if not self.built: + raise ValueError('This model has never been called, thus its weights ' + 'have not yet been created, so no summary can be ' + 'displayed. Build the model first ' + '(e.g. by calling it on some data).') print_layer_summary(self, line_length=line_length, positions=positions,