Helper function to write summaries. Args: name: name of the summary tensor: main tensor to form the summary function: function taking a tag and a scope which writes the summary family: optional, the summary's family Returns: The result of writing the summary.
(name, tensor, function, family=None)
| 702 | |
| 703 | |
| 704 | def summary_writer_function(name, tensor, function, family=None): |
| 705 | """Helper function to write summaries. |
| 706 | |
| 707 | Args: |
| 708 | name: name of the summary |
| 709 | tensor: main tensor to form the summary |
| 710 | function: function taking a tag and a scope which writes the summary |
| 711 | family: optional, the summary's family |
| 712 | |
| 713 | Returns: |
| 714 | The result of writing the summary. |
| 715 | """ |
| 716 | name_scope = ops.get_name_scope() |
| 717 | if name_scope: |
| 718 | # Add a slash to allow reentering the name scope. |
| 719 | name_scope += "/" |
| 720 | def record(): |
| 721 | with ops.name_scope(name_scope), summary_op_util.summary_scope( |
| 722 | name, family, values=[tensor]) as (tag, scope): |
| 723 | with ops.control_dependencies([function(tag, scope)]): |
| 724 | return constant_op.constant(True) |
| 725 | |
| 726 | if context.context().summary_writer is None: |
| 727 | return control_flow_ops.no_op() |
| 728 | with ops.device("cpu:0"): |
| 729 | op = smart_cond.smart_cond( |
| 730 | should_record_summaries(), record, _nothing, name="") |
| 731 | if not context.executing_eagerly(): |
| 732 | ops.add_to_collection(ops.GraphKeys._SUMMARY_COLLECTION, op) # pylint: disable=protected-access |
| 733 | return op |
| 734 | |
| 735 | |
| 736 | def generic(name, tensor, metadata=None, family=None, step=None): |
no test coverage detected