public final class EagerSession extends Object implements ExecutionEnvironment, AutoCloseable
Eager execution is an imperative programming environment that evaluates operations
immediately, without building graphs. Operations return concrete values instead of constructing a
computational graph to run later, as with Graph
s and Session
s.
This makes it easy to develop with TensorFlow and debug models, as it behaves more like a standard programming library.
Instances of a EagerSession
are thread-safe.
WARNING: Resources consumed by an EagerSession
object must be explicitly freed
by invoking the close()
method when it is no longer needed. This could be achieve using
the `try-with-resources` technique as the example below:
try (EagerSession s = EagerSession.create()) {
// execute operations eagerly
}
In addition, EagerSession
objects clean up unused resources during the session, working
in pair with the JVM garbage collector. See EagerSession.ResourceCleanupStrategy
for more details.Modifier and Type | Class and Description |
---|---|
static class |
EagerSession.DevicePlacementPolicy
Controls how to act when we try to run an operation on a given device but some input tensors
are not on that device.
|
static class |
EagerSession.Options |
static class |
EagerSession.ResourceCleanupStrategy
Controls how TensorFlow resources are cleaned up when they are no longer needed.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
static EagerSession |
create()
Returns an
EagerSession configured with default options. |
OperationBuilder |
opBuilder(String type,
String name)
Returns a builder to create a new
Operation . |
static EagerSession.Options |
options()
Returns an object that configures and builds a
EagerSession with custom options. |
public static EagerSession.Options options()
EagerSession
with custom options.public static EagerSession create()
EagerSession
configured with default options.public void close()
close
in interface AutoCloseable
public OperationBuilder opBuilder(String type, String name)
ExecutionEnvironment
Operation
.opBuilder
in interface ExecutionEnvironment
type
- of the Operation (i.e., identifies the computation to be performed)name
- to refer to the created Operation in this environment scope.OperationBuilder
to create an Operation when OperationBuilder.build()
is invoked. If OperationBuilder.build()
is not invoked,
then some resources may leak.Copyright © 2015–2019. All rights reserved.