Class: Tensorflow::OpSpec

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

Overview

OpSpec is the specification of an Operation to be added to a Graph (using Graph AddOperation).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, type = nil, attribute = nil, input = nil, inputlist = nil) ⇒ OpSpec

Name by which the added operation will be referred to in the Graph. If omitted, defaults to Type. Inputs to this operation, which in turn must be outputs of other operations already added to the Graph.

An operation may have multiple inputs with individual inputs being either a single tensor produced by another operation or a list of tensors produced by multiple operations. For example, the “Concat” operation takes two inputs: (1) the dimension along which to concatenate and (2) a list of tensors to concatenate. Thus, for Concat, len(Input) must be 2, with the first element being an Output and the second being an OutputList. Map from attribute name to its value that will be attached to this operation. Other possible fields: Device, ColocateWith, ControlInputs.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/tensorflow/opspec.rb', line 25

def initialize(name = nil, type = nil, attribute = nil, input = nil, inputlist = nil)
    self.name = name
    self.type = type
    self.attr = if attribute.nil?
                    {}
                else
                    attribute
                end
    self.input = if input.nil?
                     []
                 else
                     input
                end
    self.inputlist = if inputlist.nil?
                         []
                     else
                         inputlist
                end
    raise 'The operation specification is either input or inputlist but not both.' if !input.nil? && !inputlist.nil?
end

Instance Attribute Details

#attrObject

Name by which the added operation will be referred to in the Graph. If omitted, defaults to Type. Inputs to this operation, which in turn must be outputs of other operations already added to the Graph.

An operation may have multiple inputs with individual inputs being either a single tensor produced by another operation or a list of tensors produced by multiple operations. For example, the “Concat” operation takes two inputs: (1) the dimension along which to concatenate and (2) a list of tensors to concatenate. Thus, for Concat, len(Input) must be 2, with the first element being an Output and the second being an OutputList. Map from attribute name to its value that will be attached to this operation. Other possible fields: Device, ColocateWith, ControlInputs.



25
26
27
# File 'lib/tensorflow/opspec.rb', line 25

def attr
  @attr
end

#inputObject

Name by which the added operation will be referred to in the Graph. If omitted, defaults to Type. Inputs to this operation, which in turn must be outputs of other operations already added to the Graph.

An operation may have multiple inputs with individual inputs being either a single tensor produced by another operation or a list of tensors produced by multiple operations. For example, the “Concat” operation takes two inputs: (1) the dimension along which to concatenate and (2) a list of tensors to concatenate. Thus, for Concat, len(Input) must be 2, with the first element being an Output and the second being an OutputList. Map from attribute name to its value that will be attached to this operation. Other possible fields: Device, ColocateWith, ControlInputs.



25
26
27
# File 'lib/tensorflow/opspec.rb', line 25

def input
  @input
end

#inputlistObject

Returns the value of attribute inputlist.



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

def inputlist
  @inputlist
end

#nameObject

Name by which the added operation will be referred to in the Graph. If omitted, defaults to Type. Inputs to this operation, which in turn must be outputs of other operations already added to the Graph.

An operation may have multiple inputs with individual inputs being either a single tensor produced by another operation or a list of tensors produced by multiple operations. For example, the “Concat” operation takes two inputs: (1) the dimension along which to concatenate and (2) a list of tensors to concatenate. Thus, for Concat, len(Input) must be 2, with the first element being an Output and the second being an OutputList. Map from attribute name to its value that will be attached to this operation. Other possible fields: Device, ColocateWith, ControlInputs.



25
26
27
# File 'lib/tensorflow/opspec.rb', line 25

def name
  @name
end

#typeObject

Type of the operation (e.g., “Add”, “MatMul”).



25
26
27
# File 'lib/tensorflow/opspec.rb', line 25

def type
  @type
end