Class: Tensorflow::Operation

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

Overview

Operation that has been added to the graph.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(c_representation, graph) ⇒ Operation

A reference to the Graph to prevent it from being GCed while the Operation is still alive.



50
51
52
53
# File 'lib/tensorflow/operation.rb', line 50

def initialize(c_representation, graph)
    self.c = c_representation
    self.g = graph
end

Instance Attribute Details

#cObject

contains the graph representation.



50
51
52
# File 'lib/tensorflow/operation.rb', line 50

def c
  @c
end

#gObject

A reference to the Graph to prevent it from being GCed while the Operation is still alive.



50
51
52
# File 'lib/tensorflow/operation.rb', line 50

def g
  @g
end

Instance Method Details

#nameObject

Name returns the name of the operation.



56
57
58
# File 'lib/tensorflow/operation.rb', line 56

def name
    Tensorflow::TF_OperationName(c)
end

#num_outputsObject

NumOutputs returns the number of outputs of op.



66
67
68
# File 'lib/tensorflow/operation.rb', line 66

def num_outputs
    Tensorflow::TF_OperationNumOutputs(c)
end

#output(i) ⇒ Object

Output returns the i-th output of op.



84
85
86
87
88
89
# File 'lib/tensorflow/operation.rb', line 84

def output(i)
    out = Tensorflow::Output.new
    out.operation = self
    out.index = i
    out
end

#output_list_size(output) ⇒ Object

OutputListSize returns the size of the list of Outputs that is produced by a named output of op.

An Operation has multiple named outputs, each of which produces either a single tensor or a list of tensors. This method returns the size of the list of tensors for a specific output of the operation, identified by its name.



77
78
79
80
81
# File 'lib/tensorflow/operation.rb', line 77

def output_list_size(output)
    cname = CString(output)
    status = Tensorflow::Status.new
    Tensorflow::TF_OperationOutputListLength(c, cname, status.c)
end

#typeObject

Type returns the name of the operator used by this operation.



61
62
63
# File 'lib/tensorflow/operation.rb', line 61

def type
    Tensorflow::TF_OperationOpType(c)
end