@@ -84,9 +84,7 @@ def scalar(name, scalar, collections=None):
8484 ValueError: If tensor has the wrong shape or type.
8585 """
8686 name = _clean_tag (name )
87- if not isinstance (scalar , float ):
88- # try conversion, if failed then need handle by user.
89- scalar = float (scalar )
87+ scalar = float (scalar )
9088 return Summary (value = [Summary .Value (tag = name , simple_value = scalar )])
9189
9290
@@ -182,8 +180,6 @@ def make_image(tensor):
182180 encoded_image_string = image_string )
183181
184182def audio (tag , tensor , sample_rate = 44100 ):
185- tensor = tensor .squeeze ()
186- assert tensor .dim ()== 1 , 'input tensor should be 1 dimensional.'
187183 tensor_list = [int (32767.0 * x ) for x in tensor ]
188184 import io
189185 import wave
@@ -212,69 +208,3 @@ def text(tag, text):
212208 tensor = TensorProto (dtype = 'DT_STRING' , string_val = [text .encode (encoding = 'utf_8' )])
213209 return Summary (value = [Summary .Value (node_name = tag , metadata = smd , tensor = tensor )])
214210
215-
216- '''
217- def merge(inputs, collections=None, name=None):
218- # pylint: disable=line-too-long
219- """Merges summaries.
220- This op creates a
221- [`Summary`](https://www.tensorflow.org/code/tensorflow/core/framework/summary.proto)
222- protocol buffer that contains the union of all the values in the input
223- summaries.
224- When the Op is run, it reports an `InvalidArgument` error if multiple values
225- in the summaries to merge use the same tag.
226- Args:
227- inputs: A list of `string` `Tensor` objects containing serialized `Summary`
228- protocol buffers.
229- collections: Optional list of graph collections keys. The new summary op is
230- added to these collections. Defaults to `[GraphKeys.SUMMARIES]`.
231- name: A name for the operation (optional).
232- Returns:
233- A scalar `Tensor` of type `string`. The serialized `Summary` protocol
234- buffer resulting from the merging.
235- """
236- # pylint: enable=line-too-long
237- name = _clean_tag(name)
238- with _ops.name_scope(name, 'Merge', inputs):
239- # pylint: disable=protected-access
240- val = _gen_logging_ops._merge_summary(inputs=inputs, name=name)
241- _collect(val, collections, [])
242- return val
243-
244-
245- def merge_all(key=_ops.GraphKeys.SUMMARIES):
246- """Merges all summaries collected in the default graph.
247- Args:
248- key: `GraphKey` used to collect the summaries. Defaults to
249- `GraphKeys.SUMMARIES`.
250- Returns:
251- If no summaries were collected, returns None. Otherwise returns a scalar
252- `Tensor` of type `string` containing the serialized `Summary` protocol
253- buffer resulting from the merging.
254- """
255- summary_ops = _ops.get_collection(key)
256- if not summary_ops:
257- return None
258- else:
259- return merge(summary_ops)
260-
261-
262- def get_summary_description(node_def):
263- """Given a TensorSummary node_def, retrieve its SummaryDescription.
264- When a Summary op is instantiated, a SummaryDescription of associated
265- metadata is stored in its NodeDef. This method retrieves the description.
266- Args:
267- node_def: the node_def_pb2.NodeDef of a TensorSummary op
268- Returns:
269- a summary_pb2.SummaryDescription
270- Raises:
271- ValueError: if the node is not a summary op.
272- """
273-
274- if node_def.op != 'TensorSummary':
275- raise ValueError("Can't get_summary_description on %s" % node_def.op)
276- description_str = _compat.as_str_any(node_def.attr['description'].s)
277- summary_description = SummaryDescription()
278- _json_format.Parse(description_str, summary_description)
279- return summary_description
280- '''
0 commit comments