Class: Tensorflow::Output
- Inherits:
-
Object
- Object
- Tensorflow::Output
- Defined in:
- lib/tensorflow/operation.rb
Overview
Output represents one of the outputs of an operation in the graph. Has a DataType (and eventually a Shape). May be passed as an input argument to a function for adding operations to a graph, or to a Session’s Run() method to fetch that output as a tensor.
Instance Attribute Summary collapse
-
#index ⇒ Object
Index specifies the index of the output within the Operation.
-
#operation ⇒ Object
Index specifies the index of the output within the Operation.
Instance Method Summary collapse
-
#c ⇒ Object
Index specifies the index of the output within the Operation.
-
#dataType ⇒ Object
DataType returns the type of elements in the tensor produced by p.
-
#shape ⇒ Object
Shape returns the (possibly incomplete) shape of the tensor produced p.
Instance Attribute Details
#index ⇒ Object
Index specifies the index of the output within the Operation. Operation is the Operation that produces this Output.
12 13 14 |
# File 'lib/tensorflow/operation.rb', line 12 def index @index end |
#operation ⇒ Object
Index specifies the index of the output within the Operation. Operation is the Operation that produces this Output.
12 13 14 |
# File 'lib/tensorflow/operation.rb', line 12 def operation @operation end |
Instance Method Details
#c ⇒ Object
Index specifies the index of the output within the Operation. Operation is the Operation that produces this Output.
12 13 14 |
# File 'lib/tensorflow/operation.rb', line 12 def c Tensorflow.input(operation.c, index) end |
#dataType ⇒ Object
DataType returns the type of elements in the tensor produced by p.
17 18 19 |
# File 'lib/tensorflow/operation.rb', line 17 def dataType Tensorflow::TF_OperationOutputType(c) end |
#shape ⇒ Object
Shape returns the (possibly incomplete) shape of the tensor produced p.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/tensorflow/operation.rb', line 22 def shape status = Tensorflow::Status.new port = c ndims = Tensorflow::TF_GraphGetTensorNumDims(operation.g.c, port, status.c) raise 'Operation improperly specified.' if status.code != 0 # This should not be possible since an error only occurs if # the operation does not belong to the graph. It should not # be possible to construct such an Operation object. return nil if ndims < 0 return [] if ndims == 0 c_array = Tensorflow::Long_long.new(ndims) Tensorflow::TF_GraphGetTensorShape(operation.g.c, port, c_array, ndims, status.c) dimension_array = [] (0..ndims - 1).each do |i| dimension_array.push(c_array[i]) end dimension_array end |