Class: Tensorflow::ResourceSummaryWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/tensorflow/resource_summary_writer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shared_name: "", container: "") ⇒ ResourceSummaryWriter

Returns a new instance of ResourceSummaryWriter.



6
7
8
9
10
# File 'lib/tensorflow/resource_summary_writer.rb', line 6

def initialize(shared_name: "", container: "")
  self.step = 1
  @resource = RawOps.summary_writer(shared_name: shared_name, container: container)
  @initializer = yield @resource
end

Instance Attribute Details

#initializerObject (readonly)

Returns the value of attribute initializer.



4
5
6
# File 'lib/tensorflow/resource_summary_writer.rb', line 4

def initializer
  @initializer
end

#stepObject

Returns the value of attribute step.



3
4
5
# File 'lib/tensorflow/resource_summary_writer.rb', line 3

def step
  @step
end

Instance Method Details

#audio(tag, tensor, sample_rate, max_outputs: 3) ⇒ Object



24
25
26
27
28
29
# File 'lib/tensorflow/resource_summary_writer.rb', line 24

def audio(tag, tensor, sample_rate, max_outputs: 3)
  tensor = Tensor.from_value(tensor, dtype: :float)
  result = RawOps.write_audio_summary(@resource, self.step, tag, tensor, sample_rate, max_outputs: max_outputs)
  ExecutionContext.current.add_to_collection(Graph::GraphKeys::SUMMARY_COLLECTION, result)
  result
end

#closeObject



74
75
76
# File 'lib/tensorflow/resource_summary_writer.rb', line 74

def close
  RawOps.close_summary_writer(@resource)
end

#create_summary_metadata(display_name, description) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/tensorflow/resource_summary_writer.rb', line 12

def (display_name, description)
   = .new
  .display_name = display_name
  .summary_description = description
  .plugin_data = .PluginData.new
  .plugin_data.plugin_name = 'scalars'
end

#flushObject



70
71
72
# File 'lib/tensorflow/resource_summary_writer.rb', line 70

def flush
  RawOps.flush_summary_writer(@resource)
end

#graph(graph) ⇒ Object



31
32
33
# File 'lib/tensorflow/resource_summary_writer.rb', line 31

def graph(graph)
  RawOps.write_graph_summary(@resource, self.step, graph.as_graph_def)
end

#histogram(tag, values) ⇒ Object



35
36
37
38
39
# File 'lib/tensorflow/resource_summary_writer.rb', line 35

def histogram(tag, values)
  result = RawOps.write_histogram_summary(@resource, self.step, tag, values)
  ExecutionContext.current.add_to_collection(Graph::GraphKeys::SUMMARY_COLLECTION, result)
  result
end

#image(tag, tensor, bad_color = nil) ⇒ Object



41
42
43
44
45
46
# File 'lib/tensorflow/resource_summary_writer.rb', line 41

def image(tag, tensor, bad_color=nil)
  bad_color ||= Tensor.new([255, 0, 0, 255], dtype: :uint8)
  result = RawOps.write_image_summary(@resource, self.step, tag, tensor, bad_color)
  ExecutionContext.current.add_to_collection(Graph::GraphKeys::SUMMARY_COLLECTION, result)
  result
end

#proto(tag, tensor) ⇒ Object



48
49
50
51
52
# File 'lib/tensorflow/resource_summary_writer.rb', line 48

def proto(tag, tensor)
  result = RawOps.write_raw_proto_summary(@resource, self.step, tensor)
  ExecutionContext.current.add_to_collection(Graph::GraphKeys::SUMMARY_COLLECTION, result)
  result
end

#scalar(tag, value, dtype: nil) ⇒ Object



54
55
56
57
58
# File 'lib/tensorflow/resource_summary_writer.rb', line 54

def scalar(tag, value, dtype: nil)
  result = RawOps.write_scalar_summary(@resource, self.step, tag, value, typeT: dtype)
  ExecutionContext.current.add_to_collection(Graph::GraphKeys::SUMMARY_COLLECTION, result)
  result
end

#write(tag, value, metadata: "".b) ⇒ Object Also known as: generic



60
61
62
63
64
65
66
67
# File 'lib/tensorflow/resource_summary_writer.rb', line 60

def write(tag, value, metadata: "".b)
  value = Tensor.new(value)
  dtype ||= value.dtype

  result = RawOps.write_summary(@resource, step, value, tag, , typeT: dtype)
  ExecutionContext.current.add_to_collection(Graph::GraphKeys::SUMMARY_COLLECTION, result)
  result
end