/
summaries.jl
52 lines (41 loc) · 1.15 KB
/
summaries.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
module summary_ops
export
scalar,
audio,
histogram,
merge_all,
image
import TensorFlow
const tf = TensorFlow
for (jl_func, op) in [
(:scalar, :scalar_summary),
(:audio, :audio_summary_v2),
(:histogram, :histogram_summary),
(:image, :image_summary)
]
@eval @tf.op function $jl_func(args...; collections=[:Summaries], kwargs...)
res = tf.Ops.$op(args...; kwargs...)
foreach(c->tf.add_to_collection(c, res), collections)
res
end
# Set the documentation of the summary function to the same as the
# documentation of the underlying TensorFlow op
@eval @doc(@doc(tf.Ops.$op), $jl_func)
end
const merge = tf.Ops.merge_summary
"""
merge_all(key=:Summaries)
Merges all summaries collected in the default graph.
Args:
`key`: `GraphKey` used to collect the summaries. Defaults to
`:Summaries`
Returns:
If no summaries were collected, returns nothing. Otherwise returns a scalar
`Tensor` of type `String` containing the serialized `Summary` protocol
buffer resulting from the merging.
"""
function merge_all(key=:Summaries)
tensors = tf.get_collection(key)
merge(tensors)
end
end