Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TensorFlow: How to merge multiple 'collections'?

I have some collections that I would like to track with TensorBoard using a supervisor. In the Supervisor initializer I would like something to the effect

summary_op = tf.summary.merge_all(['test', 'valid'])

But I get the error TypeError: unhashable type: 'list', because the key must be a string (see documentation).



Edit:

This doesn't work either:

summary_op = [tf.summary.merge_all('train'), tf.summary.merge_all('valid')]
like image 372
Toke Faurby Avatar asked Jan 19 '26 19:01

Toke Faurby


1 Answers

Try tf.summary.merge(), e.g. like so:

summary_op = tf.summary.merge([
        tf.summary.merge_all('test'),
        tf.summary.merge_all('train')],
    collections='merged')

This would merge all summaries from the test and train collections and add them to a new merged collection. Keep in mind that this will result in strange effects if the same summary is used multiple times during the same time step:

Same summaries, same time step

Here I was accidentally (manually!) storing validation summaries during training runs and then again in a separate validation run.

Also I'm not sure if this is the most efficient way to go about it, but it certainly works.

like image 175
sunside Avatar answered Jan 22 '26 09:01

sunside