|TensorFlow 1 version||View source on GitHub|
Represents a graph node that performs computation on tensors.
Compat aliases for migration
See Migration guide for more details.
tf.Operation( node_def, g, inputs=None, output_types=None, control_inputs=None, input_types=None, original_op=None, op_def=None )
Operation is a node in a
tf.Graph that takes zero or more
objects as input, and produces zero or more
Tensor objects as output.
Objects of type
Operation are created by calling a Python op constructor
tf.matmul) within a
tf.function or under a
For example, within a
c = tf.matmul(a, b) creates an
Operation of type "MatMul" that takes tensors
b as input, and
c as output.
Operation. Used for attributes of
inputattribute is irrelevant here as it will be computed when generating the model.
Graph. The parent graph.
inputs: list of
Tensorobjects. The inputs to this
output_types: list of
DTypeobjects. List of the types of the
Tensorscomputed by this operation. The length of this list indicates the number of output endpoints of the
control_inputs: list of operations or tensors from which to have a control dependency.
input_types: List of
DTypeobjects representing the types of the tensors accepted by the
Operation. By default uses
[x.dtype.base_dtype for x in inputs]. Operations that expect reference-typed inputs must specify these explicitly.
original_op: Optional. Used to associate the new
Operationwith an existing
Operation(for example, a replica with the op that was replicated).
op_def: Optional. The
op_def_pb2.OpDefproto that describes the op type that this
Operationobjects on which this op has a control dependency.
Before this op is executed, TensorFlow will ensure that the operations in
self.control_inputshave finished executing. This mechanism can be used to run ops sequentially for performance reasons, or to ensure that the side effects of an op are observed in the correct order.
device: The name of the device to which this op has been assigned, if any.
Graphthat contains this operation.
inputs: The sequence of
Tensorobjects representing the data inputs of this op.
name: The full name of this operation.
node_def: Returns the
NodeDefrepresentation of this operation.
op_def: Returns the
OpDefproto that represents the type of this op.
outputs: The list of
Tensorobjects representing the outputs of this op.
traceback: Returns the call stack from when this operation was constructed.
type: The type of the op (e.g.
TypeError: if control inputs are not Operations or Tensors, or if
node_defis not a
NodeDef, or if
gis not a
Graph, or if
inputsare not tensors, or if
ValueError: if the
node_defname is not valid.
Returns the list of colocation groups of the op.
get_attr( name )
Returns the value of the attr of this op with the given
name: The name of the attr to fetch.
The value of the attr, as a Python object.
ValueError: If this op does not have an attr with the given
run( feed_dict=None, session=None )
Runs this operation in a
Calling this method will execute all preceding operations that produce the inputs needed for this operation.
N.B. Before invoking
Operation.run(), its graph must have been
launched in a session, and either a default session must be
session must be specified explicitly.
feed_dict: A dictionary that maps
Tensorobjects to feed values. See
tf.Session.runfor a description of the valid feed values.
session: (Optional.) The
Sessionto be used to run to this operation. If none, the default session will be used.
DEPRECATED: Use outputs.