Search code examples
tensorflowtensorboard

Using tensorboard with Jupyter notebooks


I'm trying to send some values to tensorboard from Jupyter notebook

with tf.Session() as sess:
    param = tf.Variable(0.1)
    param_summary = tf.scalar_summary("param", param)
    merge_op = tf.merge_all_summaries()
    writer = tf.train.SummaryWriter("/tmp/tflogs/test_tb", sess.graph)

    init = tf.initialize_all_variables()
    sess.run(init)

    for i in range(10):
        ass = tf.assign(param, i*0.5)
        sess.run(ass)
        mo = sess.run(merge_op) # Fails with "Duplicate tag param found in summary inputs" message
        writer.add_summary(mo,i)
        writer.flush()

The problem is that it fails after the first run with InvalidArgumentError: Duplicate tag param found in summary inputs message (full text here: http://pastebin.com/dTBdCkHc)

How do I make it work with consequent runs?


Solution

  • I got around this by adding this at the end of the cell or in another cell to be run in between runs.

    tf.reset_default_graph()
    

    The other thing you could try is to use

    sess = tf.InteractiveSession()