提交 e18c28a1 编写于 作者: T TensorFlower Gardener

Merge pull request #15318 from krishrustagi:changes

PiperOrigin-RevId: 395504462
...@@ -2534,11 +2534,10 @@ class Model(base_layer.Layer, version_utils.ModelVersionSelector): ...@@ -2534,11 +2534,10 @@ class Model(base_layer.Layer, version_utils.ModelVersionSelector):
ValueError: if `summary()` is called before the model is built. ValueError: if `summary()` is called before the model is built.
""" """
if not self.built: if not self.built:
raise ValueError('This model has not yet been built. ' raise ValueError(
'Build the model first by calling `build()` or calling ' 'This model has not yet been built. '
'`fit()` with some data, or specify ' 'Build the model first by calling `build()` or by calling '
'an `input_shape` argument in the first layer(s) for ' 'the model on a batch of data.')
'automatic build.')
layer_utils.print_summary( layer_utils.print_summary(
self, self,
line_length=line_length, line_length=line_length,
......
...@@ -135,8 +135,15 @@ def model_to_dot(model, ...@@ -135,8 +135,15 @@ def model_to_dot(model,
`subgraph=True`. `subgraph=True`.
Raises: Raises:
ValueError: if `model_to_dot` is called before the model is built.
ImportError: if graphviz or pydot are not available. ImportError: if graphviz or pydot are not available.
""" """
if not model.built:
raise 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.')
from keras.layers import wrappers from keras.layers import wrappers
from keras.engine import sequential from keras.engine import sequential
from keras.engine import functional from keras.engine import functional
...@@ -394,10 +401,19 @@ def plot_model(model, ...@@ -394,10 +401,19 @@ def plot_model(model,
show_layer_activations: Display layer activations (only for layers that show_layer_activations: Display layer activations (only for layers that
have an `activation` property). have an `activation` property).
Raises:
ValueError: if `plot_model` is called before the model is built.
Returns: Returns:
A Jupyter notebook Image object if Jupyter is installed. A Jupyter notebook Image object if Jupyter is installed.
This enables in-line display of the model plots in notebooks. This enables in-line display of the model plots in notebooks.
""" """
if not model.built:
raise 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.')
dot = model_to_dot( dot = model_to_dot(
model, model,
show_shapes=show_shapes, show_shapes=show_shapes,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册