New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
contrib outputs_collections bug #3721
Comments
@martinwicke Is this a |
Yes, thanks. @sguada: I hadn't noticed the commit that introduced these. As a general rule, we always only had tensors in the collections, and rely on this in several places. I recall a conversation where we discussed this type of change and decided that the tensor names themselves would be enough. We should revisit that decision and talk about what we want and make it consistent, or we should revert that change. |
This also seems to have broken
A temporary workaround/fix would be nice. |
Yes, I might have changed a few things in my code before getting the output that I showed in the issue. A temporary workaround is to manually add each activation into the tf.GraphKeys.ACTIVATIONS collection. Edit: just to clarify, |
working in a fix. |
Problem description
TensorFlow version r0.10
It seems to me that there is a bug with the outputs_collections in tensorflow/tensorflow/contrib/layers. When trying to add the outputs of the layers (say, conv2d) to the tf.GraphKeys.ACTIVATIONS collection, I run into errors with NamedOutputs such as the following:
Root of problem
README and code are not consistent
The readme (located at tensorflow/tensorflow/contrib/layers/README.md) indicates that "weights, biases, and activations (i.e., outputs) are, by default, added to the specified collections." They even show a piece of code such as
output_collections=(tf.GraphKeys.ACTIVATIONS,)
. However, looking into the code in tensorflow/tensorflow/contrib/layers/python/layers/layers.py it seems to me that there is nothing adding activations to the tf.GraphKeys.ACTIVATIONS collection. I believe one solution to this problem is to use the_apply_activation
function already written in the file:instead of using only
Code walkthrough
tensorflow/tensorflow/contrib/layers/python/layers/layers.py uses this line several times (such as in conv2d):
utils.collect_named_outputs(outputs_collections, sc, outputs)
Opening tensorflow/tensorflow/contrib/layers/python/layers/utils.py we see that this ultimately calls:
ops.add_to_collections(collections, NamedOutputs(name, outputs))
However, it seems to me that when using the summarize_activations function in https://github.com/tensorflow/tensorflow/blob/r0.10/tensorflow/contrib/layers/python/layers/summaries.py, it expects the value to be
outputs
rather thanNamedOutputs(name, outputs)
. In other words, the summarize_activations function seems to expect something along the lines of:ops.add_to_collections(collections, outputs)
rather than
ops.add_to_collections(collections, NamedOutputs(name, outputs))
Further description (not particularly informative if you are already familiar with the tensorflow repo)
If we look into what
ops.add_to_collections
is doing, we see that in tensorflow/tensorflow/python/framework/ops.py this ultimately calls:self.add_to_collection(name, value)
add_to_collection(...)
is described in the same file as:So, our
value
here isvalue = NamedOutputs(name, outputs)
from earlier.However, if we look at the summarize_activations in tensorflow/tensorflow/contrib/layers/python/layers/summaries.py, we see that:
In other words,
summarize_collection(...)
expects the collection to contain tensors instead of NamedOutputs(name, outputs).The text was updated successfully, but these errors were encountered: