A data flow graph representing a TensorFlow computation.
Instances of a Graph are threadsafe.
WARNING: Resources consumed by the Graph object must be explicitly freed by invoking
the close()
method then the Graph object is no longer needed.
Public Constructors
Graph()
Create an empty Graph.

Public Methods
Output[]<?> 
addGradients(Output[]<?> y, Output[]<?> x, Output[]<?> dx)
Adds operations to compute the partial derivatives of sum of
y s w.r.t x s,
i.e., d(y_1 + y_2 + ...)/dx_1, d(y_1 + y_2 + ...)/dx_2...

Output[]<?> 
addGradients(Output<?> y, Output[]<?> x)
Adds operations to compute the partial derivatives of sum of
y s w.r.t x s,
i.e., dy/dx_1, dy/dx_2...
This is a simplified version of {@link #addGradients(Output[], Output[], Output[]) where {@code y} is a single output and {@code dx} is null. 
void 
close()
Release resources associated with the Graph.

void 
importGraphDef(byte[] graphDef, String prefix)
Import a serialized representation of a TensorFlow graph.

void 
importGraphDef(byte[] graphDef)
Import a serialized representation of a TensorFlow graph.

OperationBuilder  
Operation 
operation(String name)
Returns the operation (node in the Graph) with the provided name.

Iterator<Operation> 
operations()
Iterator over all the
Operation s in the graph. 
byte[] 
toGraphDef()
Generate a serialized representation of the Graph.

Inherited Methods
Public Constructors
public Graph ()
Create an empty Graph.
Public Methods
public Output[]<?> addGradients (Output[]<?> y, Output[]<?> x, Output[]<?> dx)
Adds operations to compute the partial derivatives of sum of y
s w.r.t x
s,
i.e., d(y_1 + y_2 + ...)/dx_1, d(y_1 + y_2 + ...)/dx_2...
dx
are used as initial gradients (which represent the symbolic partial derivatives of some loss function
L
w.r.t. y
). dx
must be null or have size of y
.
If dx
is null, the implementation will use dx of ERROR(OnesLike/org.tensorflow.op.core.OnesLike OnesLike)
for all
shapes in y
.
Parameters
y  output of the function to derive 

x  inputs of the function for which partial derivatives are computed 
dx  if not null, the partial derivatives of some loss function L w.r.t. y 
Returns
 the partial derivatives
dy
with the size ofx
public Output[]<?> addGradients (Output<?> y, Output[]<?> x)
Adds operations to compute the partial derivatives of sum of y
s w.r.t x
s,
i.e., dy/dx_1, dy/dx_2...
This is a simplified version of {@link #addGradients(Output[], Output[], Output[]) where {@code y} is a single output and {@code dx} is null.
Parameters
y  output of the function to derive 

x  inputs of the function for which partial derivatives are computed 
Returns
 the partial derivatives
dy
with the size ofx
public void close ()
Release resources associated with the Graph.
Blocks until there are no active Session
instances referring to this Graph. A Graph
is not usable after close returns.
public void importGraphDef (byte[] graphDef, String prefix)
Import a serialized representation of a TensorFlow graph.
Parameters
graphDef  the serialized representation of a TensorFlow graph. 

prefix  a prefix that will be prepended to names in graphDef 
Throws
IllegalArgumentException  if graphDef is not a recognized serialization of a graph. 

See Also
public void importGraphDef (byte[] graphDef)
Import a serialized representation of a TensorFlow graph.
The serialized representation of the graph, often referred to as a GraphDef, can be
generated by toGraphDef()
and equivalents in other language APIs.
Parameters
graphDef 

Throws
IllegalArgumentException  if graphDef is not a recognized serialization of a graph. 

See Also
public OperationBuilder opBuilder (String type, String name)
Returns a builder to add Operation
s to the Graph.
Parameters
type  of the Operation (i.e., identifies the computation to be performed) 

name  to refer to the created Operation in the graph. 
Returns
 an
OperationBuilder
, which will add the Operation to the graph whenbuild()
is invoked. Ifbuild()
is not invoked, then some resources may leak.
public Operation operation (String name)
Returns the operation (node in the Graph) with the provided name.
Or null
if no such operation exists in the Graph.
Parameters
name 

public Iterator<Operation> operations ()
Iterator over all the Operation
s in the graph.
The order of iteration is unspecified. Consumers of the iterator will receive no notification should the underlying graph change during iteration.
public byte[] toGraphDef ()
Generate a serialized representation of the Graph.