edward icon indicating copy to clipboard operation
edward copied to clipboard

Inference not showing up in TensorBoard

Open mrosenkranz opened this issue 7 years ago • 4 comments

Hi, the various inference-related objects created by edward don't show up in tensorboard after I reset the default graph & session.

A typical workflow is that I experiment with a model by repeatedly calling tf.reset_default_graph() and tf.InteractiveSession() between two model iterations (I don't want to restart the kernel every time). Each iteration I run inference with the logdir=... option to output the graph.

In tensorboard it looks like the graph only contains the objects up to but excluding the inference step. On the other hand, tf.graph_def shows all inference-related objects so the problem seems to be with edward's output to tensorboard.

The attached tensorboard screenshot illustrates the problem. It's the output of the linked notebook.

Example notebook

edward_tf_session_issue

Btw, thanks for creating Edward! Looking forward to 2.0.

mrosenkranz avatar Feb 25 '18 09:02 mrosenkranz

Have you uncollapsed the iteration cell? IIRC it should be within iteration's scope. (At the least, it must exist somewhere in the graph.)

dustinvtran avatar Feb 25 '18 20:02 dustinvtran

It's not in iteration or any of the other cells (uncollapsed qx not shown because it didn't fit on screen): edward_tf_session_issue_uncollapsed

mrosenkranz avatar Feb 25 '18 20:02 mrosenkranz

Oh, I see. From that screenshot, it looks like inference appears across various places in the graph: iteration, the stack ops, strided slice, etc. None of those appear in your model?

To be explicit, try:

with tf.name_scope("inference"):
  inference = ed.KLqp({x: qx})
  inference.run(logdir=r'C:\tmp\log')

This will put all inference-built graph ops in the highest-level name scope.

dustinvtran avatar Feb 25 '18 20:02 dustinvtran

That did it. Thanks.

Browsing through the code I guess my issue was that the default graph is written in Inference.initialize(), which is called from VariationalInference.initialize() before any optimizer or KLqp specific nodes are added to the graph. Is the graph written that early on purpose?

mrosenkranz avatar Feb 25 '18 21:02 mrosenkranz