@Namespace(value="tensorflow") public static class tensorflow.Session extends tensorflow.AbstractSession
c++
tensorflow::GraphDef graph;
// ... Create or load graph into "graph".
// This example uses the default options which connects
// to a local runtime.
tensorflow::SessionOptions options;
std::unique_ptr<tensorflow::Session>
session(tensorflow::NewSession(options));
// Create the session with this graph.
tensorflow::Status s = session->Create(graph);
if (!s.ok()) { ... }
// Run the graph and fetch the first output of the "output"
// operation, and also run to but do not return anything
// for the "update_state" operation.
std::vector<tensorflow::Tensor> outputs;
s = session->Run({}, {"output:0"}, {"update_state"}, &outputs);
if (!s.ok()) { ... }
// Map the output as a flattened float tensor, and do something
// with it.
auto output_tensor = outputs[0].flat<float>();
if (output_tensor(0) > 0.5) { ... }
// Close the session to release the resources associated with
// this session.
session->Close();
A Session allows concurrent calls to Run(), though a Session must
be created / extended by a single thread.
Only one thread must call Close(), and Close() must only be called
after all other calls to Run() have returned.tensorflow.AbstractSession.DeleteDeallocatorPointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator| Constructor and Description |
|---|
Session(Pointer p)
Pointer cast constructor.
|
Session(tensorflow.SessionOptions options)
Calls
tensorflow.NewSession(SessionOptions) and registers a deallocator. |
| Modifier and Type | Method and Description |
|---|---|
tensorflow.Status |
Close()
\brief Closes this session.
|
tensorflow.Status |
Close(tensorflow.RunOptions run_options) |
tensorflow.Status |
Create(tensorflow.GraphDef graph)
\brief Create the graph to be used for the session.
|
tensorflow.Status |
Create(tensorflow.RunOptions run_options,
tensorflow.GraphDef graph)
NOTE: This API is still experimental and may change.
|
tensorflow.Status |
Extend(tensorflow.GraphDef graph)
\brief Adds operations to the graph that is already registered with the
Session.
|
tensorflow.Status |
Extend(tensorflow.RunOptions run_options,
tensorflow.GraphDef graph) |
tensorflow.Status |
ListDevices(tensorflow.DeviceAttributes response)
\brief List devices in the session.
|
tensorflow.Status |
LocalDeviceManager(PointerPointer output) |
tensorflow.Status |
LocalDeviceManager(tensorflow.DeviceMgr output) |
tensorflow.Status |
MakeCallable(tensorflow.CallableOptions callable_options,
long... out_handle) |
tensorflow.Status |
MakeCallable(tensorflow.CallableOptions callable_options,
LongBuffer out_handle) |
tensorflow.Status |
MakeCallable(tensorflow.CallableOptions callable_options,
LongPointer out_handle)
\brief Creates a
handle for invoking the subgraph defined by
callable_options. |
tensorflow.Status |
PRun(BytePointer handle,
tensorflow.StringTensorPairVector inputs,
tensorflow.StringVector output_names,
tensorflow.TensorVector outputs)
\brief Continues the pending execution specified by
handle with the
provided input tensors and fills outputs for the endpoints specified
in output_names. |
tensorflow.Status |
PRun(String handle,
tensorflow.StringTensorPairVector inputs,
tensorflow.StringVector output_names,
tensorflow.TensorVector outputs) |
tensorflow.Status |
PRunSetup(tensorflow.StringVector input_names,
tensorflow.StringVector output_names,
tensorflow.StringVector target_nodes,
BytePointer handle)
\brief Sets up a graph for partial execution.
|
tensorflow.Status |
ReleaseCallable(long handle)
\brief Releases resources associated with the given
handle in this
session. |
tensorflow.Status |
Run(tensorflow.RunOptions run_options,
tensorflow.StringTensorPairVector inputs,
tensorflow.StringVector output_tensor_names,
tensorflow.StringVector target_node_names,
tensorflow.TensorVector outputs,
tensorflow.RunMetadata run_metadata)
\brief Like
Run, but allows users to pass in a RunOptions proto and
to retrieve non-Tensor metadata output via a RunMetadata proto for this
step. |
tensorflow.Status |
Run(tensorflow.StringTensorPairVector inputs,
tensorflow.StringVector output_tensor_names,
tensorflow.StringVector target_node_names,
tensorflow.TensorVector outputs)
\brief Runs the graph with the provided input tensors and fills
outputs for the endpoints specified in output_tensor_names. |
tensorflow.Status |
RunCallable(long handle,
tensorflow.TensorVector feed_tensors,
tensorflow.TensorVector fetch_tensors,
tensorflow.RunMetadata run_metadata)
\brief Invokes the subgraph named by
handle with the given options and
input tensors. |
deleteaddress, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, hashCode, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetof, parseBytes, physicalBytes, position, position, put, realloc, setNull, sizeof, toString, totalBytes, totalPhysicalBytes, withDeallocator, zeropublic Session(Pointer p)
Pointer.Pointer(Pointer).public Session(tensorflow.SessionOptions options)
tensorflow.NewSession(SessionOptions) and registers a deallocator.@ByVal public tensorflow.Status Create(@Const @ByRef tensorflow.GraphDef graph)
@ByVal public tensorflow.Status Extend(@Const @ByRef tensorflow.GraphDef graph)
@ByVal public tensorflow.Status Run(@Const @ByRef tensorflow.StringTensorPairVector inputs, @Const @ByRef tensorflow.StringVector output_tensor_names, @Const @ByRef tensorflow.StringVector target_node_names, tensorflow.TensorVector outputs)
outputs for the endpoints specified in output_tensor_names.
Runs to but does not return Tensors for the nodes in
target_node_names.
The order of tensors in outputs will match the order provided
by output_tensor_names.
If Run returns OK(), then outputs->size() will be equal to
output_tensor_names.size(). If Run does not return OK(), the
state of outputs is undefined.
REQUIRES: The name of each Tensor of the input or output must
match a "Tensor endpoint" in the GraphDef passed to Create().
REQUIRES: At least one of output_tensor_names and
target_node_names must be non-empty.
REQUIRES: outputs is not nullptr if output_tensor_names is non-empty.@ByVal public tensorflow.Status Create(@Const @ByRef tensorflow.RunOptions run_options, @Const @ByRef tensorflow.GraphDef graph)
@ByVal public tensorflow.Status Extend(@Const @ByRef tensorflow.RunOptions run_options, @Const @ByRef tensorflow.GraphDef graph)
@ByVal public tensorflow.Status Close(@Const @ByRef tensorflow.RunOptions run_options)
@ByVal public tensorflow.Status Run(@Const @ByRef tensorflow.RunOptions run_options, @Const @ByRef tensorflow.StringTensorPairVector inputs, @Const @ByRef tensorflow.StringVector output_tensor_names, @Const @ByRef tensorflow.StringVector target_node_names, tensorflow.TensorVector outputs, tensorflow.RunMetadata run_metadata)
Run, but allows users to pass in a RunOptions proto and
to retrieve non-Tensor metadata output via a RunMetadata proto for this
step. run_metadata may be nullptr, in which case any metadata output is
discarded.
NOTE: This API is still experimental and may change.@ByVal public tensorflow.Status PRunSetup(@Const @ByRef tensorflow.StringVector input_names, @Const @ByRef tensorflow.StringVector output_names, @Const @ByRef tensorflow.StringVector target_nodes, @StdString @Cast(value={"char*","std::string*"}) BytePointer handle)
input_names and output_names. Returns
handle that can be used to perform a sequence of partial feeds and
fetches.
NOTE: This API is still experimental and may change.@ByVal public tensorflow.Status PRun(@StdString BytePointer handle, @Const @ByRef tensorflow.StringTensorPairVector inputs, @Const @ByRef tensorflow.StringVector output_names, tensorflow.TensorVector outputs)
handle with the
provided input tensors and fills outputs for the endpoints specified
in output_names.
NOTE: This API is still experimental and may change.@ByVal public tensorflow.Status PRun(@StdString String handle, @Const @ByRef tensorflow.StringTensorPairVector inputs, @Const @ByRef tensorflow.StringVector output_names, tensorflow.TensorVector outputs)
@ByVal public tensorflow.Status ListDevices(@StdVector tensorflow.DeviceAttributes response)
@ByVal public tensorflow.Status Close()
SessionOptions::target field).@ByVal public tensorflow.Status LocalDeviceManager(@Cast(value="const tensorflow::DeviceMgr**") PointerPointer output)
@ByVal public tensorflow.Status LocalDeviceManager(@Const @ByPtrPtr tensorflow.DeviceMgr output)
@ByVal public tensorflow.Status MakeCallable(@Const @ByRef tensorflow.CallableOptions callable_options, @Cast(value="tensorflow::Session::CallableHandle*") LongPointer out_handle)
handle for invoking the subgraph defined by
callable_options.
NOTE: This API is still experimental and may change.@ByVal public tensorflow.Status MakeCallable(@Const @ByRef tensorflow.CallableOptions callable_options, @Cast(value="tensorflow::Session::CallableHandle*") LongBuffer out_handle)
@ByVal public tensorflow.Status MakeCallable(@Const @ByRef tensorflow.CallableOptions callable_options, @Cast(value="tensorflow::Session::CallableHandle*") long... out_handle)
@ByVal public tensorflow.Status RunCallable(@Cast(value="tensorflow::Session::CallableHandle") long handle, @Const @ByRef tensorflow.TensorVector feed_tensors, tensorflow.TensorVector fetch_tensors, tensorflow.RunMetadata run_metadata)
handle with the given options and
input tensors.
The order of tensors in feed_tensors must and fetch_tensors will
match the order of names in CallableOptions::feed() and
CallableOptions::fetch() when this subgraph was created.
NOTE: This API is still experimental and may change.@ByVal public tensorflow.Status ReleaseCallable(@Cast(value="tensorflow::Session::CallableHandle") long handle)
handle in this
session.
NOTE: This API is still experimental and may change.Copyright © 2019. All rights reserved.