You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The basic issue is:
It used to be possible to precisely control the display name (or tag) of summary data in TensorBoard, because users had direct control over the tag field.
However, this meant that summary code ignored tf name scopes when generating summaries and tags. This was frustrating because it meant the following code was broken:
def layer(input):
W = get_weights_variable(somehow)
b = get_bias_variable(somehow)
activation = tf.nn.relu(input * W + b)
s = tf.summary.histogram("activation_histogram", activation)
return activation
input = tf.placeholder(...)
layer1 = layer(input)
layer2 = layer(layer1)
...
merged = tf.summary.merge_all()
....
This code would be broken because the tag "activation_histogram" would be used twice, creating a conflict.
To fix this, the summary module (which was added in tf1.0) removes explicit control of the tag from the user. Instead, the first argument to the summary is the "name", and the generated node_name is used as the summary tag. As discussed in the linked issue, however, this creates its own set of frustrations and headaches.
I think a robust solution would be to add a display_name argument to summaries, which is used to create a SummaryMetadata that TensorBoard parses. Then, TensorBoard can use the display_name as the default name in tb, and fall back to the tag in case of conflicts.
I'm not sure how to implement this in a way that generalizes to the plugin system, though. I don't want to fix it just for individual plugins. We also need to continue to support the case where users manually generate the summary proto with an explicit tag.
I'd like to increase the priority on this as we encourage summary ops to be implemented as high-level TensorFlow code instead of as core TensorFlow ops. Any op that needs to process its input at all will (should) create a name_scope for this computation, but then we can't provide a summary op of the same name.
In the meantime, we can use the following workaround: a plugin scopes its computation and creates a summary op named __internal_image_summary or something (within the name scope). Then, when the plugin backend looks at any tag, it strips a suffix /__internal_image_summary. (Graph below.) But this is certainly not something that we want to actually require plugin authors to do, and it would be great to not have it in the graph at all, so it'd be nice to have this issue resolved before we publish these new APIs.
Our own tb.summary summary APIs all support a display_name parameter that's rendered in the frontend. We are still working on making those ready for migrating people over from tf.summary, but once you're using tb.summary I think this issue is addressed.
@nfelt Apart from tf.summary and tb.summary, there is also a tf.contrib.summary. They all have different APIs. What's the differences and which one we should migrate to?
I may be out of date, but I believe the team wants tb.summary to be the canonical way to put data into TensorBoard. tf.contrib, as externally-contributed code, will not be as well supported.
@ppwwyyxx We're working on making tb.summary the future "standard" API, but it's not quite there yet and still may be subject to some changes. In particular, right now tb.summary is a layer on top of tf.summary, but in the future it will be a layer on top of tf.contrib.summary which has a somewhat different mechanism for actually emitting summaries.
If you're interested in display_name right away, you can use tb.summary today, just be sure to check the release notes when upgrading your TF/TB installation since we may make changes to the API that require some adjustments to the calling code for it to continue working.
Thanks for bearing with us and apologies for the delay. The TF 2.0 summary API actually does address the underlying issue here, even though it doesn't include display_name as I originally described.
The tl;dr is that now the string given to TF 2.0 summary ops will be directly used as the tag, except that it will be prefixed with any active name scopes. If you disable name scopes using with tf.name_scope(""): ... then you have direct control over the tag.
After running this code, pointing TensorBoard at the logdir will show the following tag names:
loss
my/arbitrary/tag
myscope/prefixed/tag
unprefixed/tag
The goal of this approach is to provide a hopefully reasonable compromise that avoids the pitfalls of the previous iterations of this functionality. For context, in TF 0.x, the tag was entirely determined by the user's string, but this makes it easy to accidentally have summary tags that collide (especially in library code) and results in unusable merged data in TensorBoard. To avoid this issue, TF 1.x used the op name, which is guaranteed to be unique, but this led to the lack of control described above, and the inability to do things like have a tag name that matched an actual op name (as described in the original issue tensorflow/tensorflow#6150). This led to workarounds like display_name, which wasn't a great solution because it required extra work (passing the name twice) and only solved part of the problem - it allowed having a summary tag with the same name as an op, but it didn't allow intentionally using the same tag for two summary ops in the same graph in order to plot them on the same chart (which came up for some users when using a single graph with separate summary writers for e.g. train and eval runs).
The new TF 2.x behavior is a halfway point that still inserts the name scope (if one is present) as a prefix to help modularize code and avoid collisions, but accepts the user-provided part of the name exactly as given. The latter makes it possible to completely customize the tag if you explicitly enter into the empty global scope. Note any code intended to be reused, like library code, should not use the global scope like this - the explicit control is there as an escape hatch for end users.
I'm optimistically closing this issue in hopes that it addresses the concerns here, but let me know if you have questions and we can discuss further.
Activity
teamdandelion commentedon Jun 16, 2017
Also see:
"Allow dynamic summary names in new summary interface"
tensorflow/tensorflow#6603
wchargin commentedon Jul 14, 2017
I'd like to increase the priority on this as we encourage summary ops to be implemented as high-level TensorFlow code instead of as core TensorFlow ops. Any op that needs to process its input at all will (should) create a
name_scopefor this computation, but then we can't provide a summary op of the same name.In the meantime, we can use the following workaround: a plugin scopes its computation and creates a summary op named

__internal_image_summaryor something (within the name scope). Then, when the plugin backend looks at any tag, it strips a suffix/__internal_image_summary. (Graph below.) But this is certainly not something that we want to actually require plugin authors to do, and it would be great to not have it in the graph at all, so it'd be nice to have this issue resolved before we publish these new APIs.Create tensor summaries for images
Add support for display_name and summary_description to the tf.summar…
Add support for display_name and summary_description to the tf.summar…
ppwwyyxx commentedon Jun 17, 2018
What's the status of the issue?
teamdandelion commentedon Jun 18, 2018
I had the most context on this issue, but I've stopped working on TensorBoard. So unless someone else has picked it up - it's basically abandoned.
nfelt commentedon Jun 18, 2018
Our own
tb.summarysummary APIs all support adisplay_nameparameter that's rendered in the frontend. We are still working on making those ready for migrating people over fromtf.summary, but once you're usingtb.summaryI think this issue is addressed.teamdandelion commentedon Jun 19, 2018
Oh, sweet! 👍
ppwwyyxx commentedon Jun 26, 2018
@nfelt Apart from
tf.summaryandtb.summary, there is also atf.contrib.summary. They all have different APIs. What's the differences and which one we should migrate to?teamdandelion commentedon Jun 28, 2018
I may be out of date, but I believe the team wants
tb.summaryto be the canonical way to put data into TensorBoard.tf.contrib, as externally-contributed code, will not be as well supported.nfelt commentedon Jul 3, 2018
@ppwwyyxx We're working on making
tb.summarythe future "standard" API, but it's not quite there yet and still may be subject to some changes. In particular, right nowtb.summaryis a layer on top oftf.summary, but in the future it will be a layer on top oftf.contrib.summarywhich has a somewhat different mechanism for actually emitting summaries.If you're interested in
display_nameright away, you can usetb.summarytoday, just be sure to check the release notes when upgrading your TF/TB installation since we may make changes to the API that require some adjustments to the calling code for it to continue working.[-]Re-enable explicit control of summary display name[/-][+]Re-enable explicit control of summary tag[/+]SiegeLordEx commentedon Apr 11, 2019
Is having this be configurable still the plan? I see the preview TF2.0 summary API does not have this feature.
nfelt commentedon Aug 14, 2019
Thanks for bearing with us and apologies for the delay. The TF 2.0 summary API actually does address the underlying issue here, even though it doesn't include
display_nameas I originally described.The tl;dr is that now the string given to TF 2.0 summary ops will be directly used as the tag, except that it will be prefixed with any active name scopes. If you disable name scopes using
with tf.name_scope(""): ...then you have direct control over the tag.Here's an TF 2.0 example to illustrate:
After running this code, pointing TensorBoard at the logdir will show the following tag names:
lossmy/arbitrary/tagmyscope/prefixed/tagunprefixed/tagThe goal of this approach is to provide a hopefully reasonable compromise that avoids the pitfalls of the previous iterations of this functionality. For context, in TF 0.x, the tag was entirely determined by the user's string, but this makes it easy to accidentally have summary tags that collide (especially in library code) and results in unusable merged data in TensorBoard. To avoid this issue, TF 1.x used the op name, which is guaranteed to be unique, but this led to the lack of control described above, and the inability to do things like have a tag name that matched an actual op name (as described in the original issue tensorflow/tensorflow#6150). This led to workarounds like
display_name, which wasn't a great solution because it required extra work (passing the name twice) and only solved part of the problem - it allowed having a summary tag with the same name as an op, but it didn't allow intentionally using the same tag for two summary ops in the same graph in order to plot them on the same chart (which came up for some users when using a single graph with separate summary writers for e.g. train and eval runs).The new TF 2.x behavior is a halfway point that still inserts the name scope (if one is present) as a prefix to help modularize code and avoid collisions, but accepts the user-provided part of the name exactly as given. The latter makes it possible to completely customize the tag if you explicitly enter into the empty global scope. Note any code intended to be reused, like library code, should not use the global scope like this - the explicit control is there as an escape hatch for end users.
I'm optimistically closing this issue in hopes that it addresses the concerns here, but let me know if you have questions and we can discuss further.