tf.Operation

View source on GitHub

Represents a graph node that performs computation on tensors.

tf.Operation(
    node_def, g, inputs=None, output_types=None, control_inputs=None,
    input_types=None, original_op=None, op_def=None
)

An Operation is a node in a tf.Graph that takes zero or more Tensor objects as input, and produces zero or more Tensor objects as output. Objects of type Operation are created by calling a Python op constructor (such as tf.matmul) within a tf.function or under a tf.Graph.as_default context manager.

For example, within a tf.function, c = tf.matmul(a, b) creates an Operation of type "MatMul" that takes tensors a and b as input, and produces c as output.

If a tf.compat.v1.Session is used, an Operation of a tf.Graph can be executed by passing it to tf.Session.run. op.run() is a shortcut for calling tf.compat.v1.get_default_session().run(op).

Args:

Attributes:

Raises:

Methods

colocation_groups

View source

colocation_groups()

Returns the list of colocation groups of the op.

get_attr

View source

get_attr(
    name
)

Returns the value of the attr of this op with the given name.

Args:

Returns:

The value of the attr, as a Python object.

Raises:

run

View source

run(
    feed_dict=None, session=None
)

Runs this operation in a Session.

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 available, or session must be specified explicitly.

Args:

values

View source

values()

DEPRECATED: Use outputs.