Run
Operation
s and evaluate
Tensors
.
A Runner runs the necessary graph fragments to execute every
Operation
required to
evaluate the
Tensors
to fetch. The
feed(String, int, Tensor)
call allows
callers to override the value of
Tensors
in the graph by substituting the
provided
Tensors
for the outputs of the operations provided to
feed(String, int, Tensor)
.
Public Constructors
Runner
()
|
Public Methods
Session.Runner | |
Session.Runner | |
Session.Runner | |
Session.Runner | |
Session.Runner | |
Session.Runner | |
Session.Runner | |
Session.Runner | |
Session.Runner | |
Session.Runner | |
List< Tensor <?>> |
run
()
Execute the graph fragments necessary to compute all requested fetches.
|
Session.Run |
runAndFetchMetadata
()
Execute graph fragments to compute requested fetches and return metadata about the run.
|
Session.Runner |
setOptions
(byte[] options)
(Experimental method): set options (typically for debugging) for this run.
|
Inherited Methods
Public Constructors
public Runner ()
Public Methods
public Session.Runner addTarget (String operation)
public Session.Runner addTarget ( Operand <?> operand)
public Session.Runner addTarget ( Operation operation)
Throws
IllegalArgumentException |
if the operation is not a
GraphOperation
|
---|
public Session.Runner feed ( Operand <?> operand, Tensor <?> t)
Use
t
instead of the Tensor referred to by executing the operation referred to by
operand
.
public Session.Runner feed (String operation, Tensor <?> t)
Avoid evaluating
operation
and substitute
t
for the value it produces.
Parameters
operation |
Is either the string name of the operation, in which case this method is a
shorthand for
feed(operation, 0)
, or it is a string of the form
operation_name:output_index
, in which case this method acts like
feed(operation_name, output_index)
. These colon-separated names are commonly used in the
SignatureDef
protocol buffer messages that are included in
metaGraphDef()
.
|
---|
public Session.Runner feed (String operation, int index, Tensor <?> t)
Avoid evaluating the
index
-th output of
operation
by substituting
t
for the value it produces.
Operations in a
Graph
can have multiple outputs,
index
identifies which
one
t
is being provided for.
public Session.Runner fetch (String operation)
Make
run()
return the output of
operation
.
Parameters
operation |
Is either the string name of the operation, in which case this method is a
shorthand for
fetch(operation, 0)
, or it is a string of the form
operation_name:output_index
, in which case this method acts like
fetch(operation_name, output_index)
. These colon-separated names are commonly used in
the
SignatureDef
protocol buffer messages that are included in
metaGraphDef()
.
|
---|
public Session.Runner fetch (String operation, int index)
public Session.Runner fetch ( Operand <?> operand)
Makes
run()
return the Tensor referred to by the output of
operand
.
public Session.Runner fetch ( Output <?> output)
Makes
run()
return the Tensor referred to by
output
.
public List< Tensor <?>> run ()
Execute the graph fragments necessary to compute all requested fetches.
WARNING:
The caller assumes ownership of all returned
Tensors
, i.e.,
the caller must call
close()
on all elements of the returned list to free up
resources.
TODO(ashankar): Reconsider the return type here. Two things in particular: (a) Make it
easier for the caller to cleanup (perhaps returning something like AutoCloseableList in
SessionTest.java), and (b) Evaluate whether the return value should be a list, or maybe a
Map<Output, Tensor>
?
TODO(andrewmyers): It would also be good if whatever is returned here made it easier to extract output tensors in a type-safe way.
public Session.Run runAndFetchMetadata ()
Execute graph fragments to compute requested fetches and return metadata about the run.
This is exactly like
run()
, but in addition to the requested Tensors, also
returns metadata about the graph execution in the form of a serialized
RunMetadata
protocol buffer
.
public Session.Runner setOptions (byte[] options)
(Experimental method): set options (typically for debugging) for this run.
The options are presented as a serialized RunOptions protocol buffer .
The org.tensorflow package is free of any protocol buffer dependencies in order to remain friendly to resource constrained systems (where something like nanoproto may be more appropriate). A cost of that is this lack of type-safety in this API function. This choice is under review and this function may be replaced by more type-safe equivalents at any time.