|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 | # ============================================================================== |
15 | | -"""Deprecated endpoints that we aren't yet ready to remove entirely. |
| 15 | +"""Non-core alias for the deprecated tf.X_summary ops. |
| 16 | +
|
| 17 | +For TensorFlow 1.0, we have re-organized the TensorFlow summary ops into a |
| 18 | +submodule, and made some semantic tweaks. The first thing to note is that we |
| 19 | +moved the APIs around as follows: |
| 20 | +
|
| 21 | +tf.scalar_summary -> tf.summary.scalar |
| 22 | +tf.histogram_summary -> tf.summary.histogram |
| 23 | +tf.audio_summary -> tf.summary.audio |
| 24 | +tf.image_summary -> tf.summary.image |
| 25 | +tf.merge_summary -> tf.summary.merge |
| 26 | +tf.merge_all_summaries -> tf.summary.merge_all |
| 27 | +
|
| 28 | +We think this is a cleaner API and will improve long-term discoverability and |
| 29 | +clarity of the TensorFlow API. However, we also took the opportunity to make an |
| 30 | +important change to how summary "tags" work. The "tag" of a summary is the |
| 31 | +string that is associated with the output data, i.e. the key for organizing the |
| 32 | +generated protobufs. |
| 33 | +
|
| 34 | +Previously, the tag was allowed to be any unique string, and had no relation |
| 35 | +to the summary op generating it, and no relation to the TensorFlow name system. |
| 36 | +This made it very difficult to write re-usable code that would add summary |
| 37 | +ops to the graph. If you had a function that would add summary ops, you would |
| 38 | +need to manually pass in a name scope to that function to create de-duplicated |
| 39 | +tags, otherwise your program would fail with a runtime error due to tag |
| 40 | +collision. |
| 41 | +
|
| 42 | +The new summary APIs under tf.summary throw away the "tag" as an independent |
| 43 | +concept; instead, the first argument is the node name. This means that summary |
| 44 | +tags now automatically inherit the surrounding TF name scope, and automatically |
| 45 | +are deduplicated if there is a conflict. However, now the only allowed |
| 46 | +characters are alphanumerics, underscores, and forward slashes. To make |
| 47 | +migration easier, the new APIs automatically convert illegal characters to |
| 48 | +underscores. |
| 49 | +
|
| 50 | +Just as an example, consider the following "before" and "after" code snippets: |
| 51 | +
|
| 52 | +# Before |
| 53 | +def add_activation_summaries(v, scope): |
| 54 | + tf.scalar_summary("%s/fraction_of_zero" % scope, tf.nn.fraction_of_zero(v)) |
| 55 | + tf.histogram_summary("%s/activations" % scope, v) |
| 56 | +
|
| 57 | +# After |
| 58 | +def add_activation_summaries(v): |
| 59 | + tf.summary.scalar("fraction_of_zero", tf.nn.fraction_of_zero(v)) |
| 60 | + tf.summary.histogram("activations", v) |
| 61 | +
|
| 62 | +Now, so long as the add_activation_summaries function is called from within the |
| 63 | +right name scope, the behavior is the same. |
| 64 | +
|
| 65 | +Because this change does modify the behavior and could break tests, we can't |
| 66 | +automatically migrate usage to the new APIs. That is why we are making the old |
| 67 | +APIs temporarily available here at tf.contrib.deprecated. |
| 68 | +
|
| 69 | +In addition to the name change described above, there are two further changes |
| 70 | +to the new summary ops: |
| 71 | +
|
| 72 | +- the "max_images" argument for tf.image_summary was renamed to "max_outputs |
| 73 | + for tf.summary.image |
| 74 | +- tf.scalar_summary accepted arbitrary tensors of tags and values. However, |
| 75 | + tf.summary.scalar requires a single scalar name and scalar value. In most |
| 76 | + cases, you can create tf.summary.scalars in a loop to get the same behavior |
| 77 | +
|
| 78 | +As before, TensorBoard will group charts by the top-level name scope. This may |
| 79 | +be inconvenient, since in the new summary ops the summary will inherit that |
| 80 | +name scope without user control. We plan to add more grouping mechanisms to |
| 81 | +TensorBoard, so it will be possible to specify the TensorBoard group for |
| 82 | +each summary via the summary API. |
| 83 | +
|
16 | 84 | """ |
17 | 85 | from __future__ import absolute_import |
18 | 86 | from __future__ import division |
19 | 87 | from __future__ import print_function |
20 | 88 |
|
| 89 | + |
21 | 90 | # pylint: disable=unused-import,line-too-long |
22 | | -from tensorflow.contrib.deprecated.summaries import audio_summary |
23 | | -from tensorflow.contrib.deprecated.summaries import histogram_summary |
24 | | -from tensorflow.contrib.deprecated.summaries import image_summary |
25 | | -from tensorflow.contrib.deprecated.summaries import merge_all_summaries |
26 | | -from tensorflow.contrib.deprecated.summaries import merge_summary |
27 | | -from tensorflow.contrib.deprecated.summaries import scalar_summary |
| 91 | +from tensorflow.python.ops.logging_ops import audio_summary |
| 92 | +from tensorflow.python.ops.logging_ops import histogram_summary |
| 93 | +from tensorflow.python.ops.logging_ops import image_summary |
| 94 | +from tensorflow.python.ops.logging_ops import merge_all_summaries |
| 95 | +from tensorflow.python.ops.logging_ops import merge_summary |
| 96 | +from tensorflow.python.ops.logging_ops import scalar_summary |
28 | 97 | # pylint: enable=unused-import,line-too-long |
0 commit comments