I have a subclassed model that instantiates a few custom layers via subclassing. I tried using keras.utils.plot_model()
but all it does is print the model block, none of the layers appeared.
Can a Tensorflow expert comment on this? Will this feature ever be implemented in the future? If not, what is the next best alternative to examine the computation graph? Note that model.summary()
only gives a summary of the parameters of the custom layer, within which contains two dense layers. Ideally, I like to see all the computations, if that is not asking too much...
Update: I dug into the source, looks like plot_model() first check for the _is_graph_network
attribute. Graph Networks are used in Functional and Sequential APIs. From the source:
Two types of
Networks
exist: Graph Networks and Subclass Networks. Graph networks are used in the Keras Functional and Sequential APIs. Subclassed networks are used when a user subclasses theModel
class. In general, more Keras features are supported with Graph Networks than with Subclassed Networks, specifically:
- Model cloning (
keras.models.clone()
)- Serialization (
model.get_config()/from_config()
,model.to_json()/to_yaml()
)- Whole-model saving (
model.save()
)
(custom graph component) Naturally, I like to know if I can build a graph network component, so my subclassed model/layer can work with these features. Does that involve a lot of effort?
(tf.function graph visualization) Can someone let me know if graph visualization via Tensorboard works with Tensorflow2 tf.functions? In Tensorflow 1.x, one defines a name scope for a logical group of ops (e.g. generator/discriminator in GAN, encoder/decoder in VAE and loss/metrics), they are then displayed as a high-level block in the graph visualization. Can I define something similar for tf.functions?