public final class Graph extends Object implements AutoCloseable
Instances of a Graph are thread-safe.
WARNING: Resources consumed by the Graph object msut be explicitly freed by invoking
the close()
method then the Graph object is no longer needed.
Constructor and Description |
---|
Graph()
Create an empty Graph.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Release resources associated with the Graph.
|
void |
importGraphDef(byte[] graphDef)
Import a serialized representation of a TensorFlow graph.
|
void |
importGraphDef(byte[] graphDef,
String prefix)
Import a serialized representation of a TensorFlow graph.
|
OperationBuilder |
opBuilder(String type,
String name)
Returns a builder to add
Operation s to the Graph. |
Operation |
operation(String name)
Returns the operation (node in the Graph) with the provided name.
|
byte[] |
toGraphDef()
Generate a serialized representation of the Graph.
|
public void close()
Blocks until there are no active Session
instances referring to this Graph. A Graph
is not usable after close returns.
close
in interface AutoCloseable
public Operation operation(String name)
Or null
if no such operation exists in the Graph.
public OperationBuilder opBuilder(String type, String name)
Operation
s to the Graph.type
- of the Operation (i.e., identifies the computation to be performed)name
- to refer to the created Operation in the graph.OperationBuilder
, which will add the Operation to the graph when OperationBuilder.build()
is invoked. If OperationBuilder.build()
is not invoked,
then some resources may leak.public void importGraphDef(byte[] graphDef) throws IllegalArgumentException
The serialized representation of the graph, often referred to as a GraphDef, can be
generated by toGraphDef()
and equivalents in other language APIs.
IllegalArgumentException
- if graphDef is not a recognized serialization of a graph.importGraphDef(byte[], String)
public void importGraphDef(byte[] graphDef, String prefix) throws IllegalArgumentException
graphDef
- the serialized representation of a TensorFlow graph.prefix
- a prefix that will be prepended to names in graphDefIllegalArgumentException
- if graphDef is not a recognized serialization of a graph.importGraphDef(byte[])
public byte[] toGraphDef()
Copyright © 2015–2017. All rights reserved.