Skip to content

Add string tensor tags to new summary interface - #5558

Closed
thuyen wants to merge 4 commits into
tensorflow:masterfrom
thuyen:summary
Closed

thuyen wants to merge 4 commits into
tensorflow:masterfrom
thuyen:summary

Conversation

@thuyen

@thuyen thuyen commented Nov 11, 2016 •

Copy link
Copy Markdown
Contributor

Old/Deprecated summary ops can accept string tensors for tags. The new summary interface only allows strings for names (subsequently used as tags). This pull adds prefix option, which can be a string tensor.

This is important because sometimes we want to define the tags symbolically based on some conditions of input placeholders.

@mention-bot

Copy link
Copy Markdown

@thuyen, thanks for your PR! By analyzing the history of the files in this pull request, we identified @danmane, @drpngx and @tensorflower-gardener to be potential reviewers.

@tensorflow-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@thuyen

thuyen commented Nov 21, 2016

Copy link
Copy Markdown
Contributor Author

@danmane @drpngx Can one of the admins have a look at this pull request?

@drpngx

drpngx commented Nov 22, 2016

Copy link
Copy Markdown
Contributor

@danmane knows best.

@teamdandelion

Copy link
Copy Markdown

Is there a need for the "prefix" argument? Why not just have the summary wrapper accept a string tensor as name, and convert it into a string?

Adding prefix as another arg seems orthogonal to the main goal of the pr

@thuyen

thuyen commented Nov 29, 2016

Copy link
Copy Markdown
Contributor Author

@danmane Could you tell me the function for string_tensor to string conversion. I couldn't find it in current API. If we have that function then we don't need this PR at all.

@thuyen

thuyen commented Nov 29, 2016

Copy link
Copy Markdown
Contributor Author

I am still not sure if such function exists since tensor value would be determined dynamically at run time while string needs static literals.

@martinwicke

Copy link
Copy Markdown
Member

What would the prefix be used for? Can't you achieve the same by wrapping the call to the summary in a name_scope?

@martinwicke martinwicke added stat:awaiting tensorflower Status - Awaiting response from tensorflower stat:awaiting response Status - Awaiting response from author and removed stat:awaiting tensorflower Status - Awaiting response from tensorflower labels Dec 13, 2016
@thuyen

thuyen commented Dec 13, 2016

Copy link
Copy Markdown
Contributor Author

name_scope couldn't be a string tensor.
With the old interface, one can create a single graph for both training and validation (like the following). In the new interface, it's only possible with some new argument prefix (a tensor) because the name argument can only be string. An example:

is_training = tf.placeholder(tf.bool)
inputs, labels = data(is_training)
outputs = model(inputs, is_training)
loss = tf.reduce_mean(tf.square(output-labels))
train_op = ....

prefix = tf.cond(is_training, lambda: tf.constant('train/'), lambda: tf.constant('valid/'))
tf.summary.scalar('loss', loss, prefix=prefix)
summary_op = tf.summary.merge_all()

# Each training iteration
sess.run([train_op, summary_op], feed_dict={is_training: True})

# Validation
sess.run(summary_op, feed_dict={is_training: False})

@foxik

foxik commented Jan 2, 2017

Copy link
Copy Markdown
Contributor

+1 for implementing some way of using string tensor as summary name.

I frequently used the following scenario, where I want to measure accuracy on train/devel/test data (to appear in different graphs in TensorBoard):

    dataset_name = tf.placeholder(tf.string, [])
    summary = tf.scalar_summary(self.dataset_name+"/accuracy", accuracy)

That way I could use the same summary with any of the data:

   summary = session.run([summary], {dataset_name:"train" / "devel" / "test"})

A prefix option would be ideal for me, but generaly any way of using string tensor is. Currently I have to create separate summary operations for every dataset I want to evaluate on.

@ppwwyyxx

ppwwyyxx commented Jan 3, 2017

Copy link
Copy Markdown
Contributor

+1 for passing an optional string/string tensor (but not prefix) as names. This would also resolve #6150

@teamdandelion teamdandelion removed the stat:awaiting response Status - Awaiting response from author label Jan 3, 2017
@drpngx

drpngx commented Jan 11, 2017

Copy link
Copy Markdown
Contributor

@dandelionmane is that the right way to go about this?

@drpngx drpngx added the stat:awaiting tensorflower Status - Awaiting response from tensorflower label Jan 24, 2017
@rmlarsen

Copy link
Copy Markdown
Contributor

@dandelionmane any advice on how to proceed here?

@teamdandelion

Copy link
Copy Markdown

@thuyen Thanks for the pull request, and sorry for the really slow review on my part.

I think this is a fine proposal. I would just like more descriptive docstrings that explain why the new argument should be used.

Comment thread tensorflow/python/summary/summary.py Outdated
tensor: A real numeric Tensor containing a single value.
collections: Optional list of graph collections keys. The new summary op is
added to these collections. Defaults to `[GraphKeys.SUMMARIES]`.
prefix: Optional string tensor

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional string tensor. If provided, it will be a prefix to the summary's tag in TensorBoard.

@teamdandelion teamdandelion left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like the docstring for "prefix" to explain how the prefix will be used. Otherwise, LGTM

@vrv vrv added the API review API Review label Feb 17, 2017
@vrv
vrv requested a review from martinwicke February 17, 2017 01:26
@vrv

vrv commented Feb 17, 2017

Copy link
Copy Markdown

Adding @martinwicke for API review triage, if needed.

Also, a test is warranted here, probably.

@teamdandelion

Copy link
Copy Markdown

Please update it for the (tensor_summary)[https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/ops/summary_ops.py#L38] as well. This will be more tricky because the tensor_summary has a different implementation and things are a little inconsistent.
Please also add tests.

In the long run, I think we may want to have all of the summaries set the node_name part of the summary protobuf according to the kernels' node name, and set the tag according to things like the prefix and the original text the user provided to the summary op (as opposed to the deduplicated, name-scope'd name)

@ppwwyyxx

Copy link
Copy Markdown
Contributor

Why the solution here is prefix instead of just giving the whole string? Giving the whole string would also fix #6150 together

@teamdandelion teamdandelion added stat:awaiting response Status - Awaiting response from author and removed stat:awaiting tensorflower Status - Awaiting response from tensorflower labels Mar 7, 2017
@martinwicke martinwicke added stat:awaiting tensorflower Status - Awaiting response from tensorflower and removed stat:awaiting response Status - Awaiting response from author labels Mar 21, 2017
@martinwicke

Copy link
Copy Markdown
Member

@dandelionmane, what about @ppwwyyxx's comment?

@drpngx

drpngx commented Apr 10, 2017

Copy link
Copy Markdown
Contributor

@dandelionmane any progress?

@thuyen

thuyen commented Apr 22, 2017

Copy link
Copy Markdown
Contributor Author

@dandelionmane tensor_summary has different interface, taking only the tensor as input, no tag, and thus couldn't take a string tensor as tag. This is probably inline with the new summary interface . I should wait for more unified solution from google and close this?

@thuyen thuyen closed this Apr 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API review API Review cla: yes stat:awaiting tensorflower Status - Awaiting response from tensorflower

Projects

None yet

Development

Successfully merging this pull request may close these issues.