W3cubDocs

/TensorFlow C++

tensorflow::ClientSession

This is an abstract class.

#include <client_session.h>

A ClientSession object lets the caller drive the evaluation of the TensorFlow graph constructed with the C++ API.

Summary

Example:

Scope root = Scope::NewRootScope();
auto a = Placeholder(root, DT_INT32);
auto c = Add(root, a, {41});

ClientSession session(root);
std::vector outputs;

Status s = session.Run({ {a, {1}} }, {c}, &outputs);
if (!s.ok()) { ... }  
Constructors and Destructors
ClientSession(const Scope & scope, const string & target)
Create a new session to evaluate the graph contained in scope by connecting to the TensorFlow runtime specified by target.
ClientSession(const Scope & scope)
Same as above, but use the empty string ("") as the target specification.
ClientSession(const Scope & scope, const SessionOptions & session_options)
Create a new session, configuring it with session_options.
Public types
FeedType typedef
std::unordered_map< Output, Input::Initializer, OutputHash >
A data type to represent feeds to a Run call.
Public functions
Run(const std::vector< Output > & fetch_outputs, std::vector< Tensor > *outputs) const
Evaluate the tensors in fetch_outputs.
Run(const FeedType & inputs, const std::vector< Output > & fetch_outputs, std::vector< Tensor > *outputs) const
Same as above, but use the mapping in inputs as feeds.
Run(const FeedType & inputs, const std::vector< Output > & fetch_outputs, const std::vector< Operation > & run_outputs, std::vector< Tensor > *outputs) const
Same as above. Additionally runs the operations ins run_outputs.
Run(const RunOptions & run_options, const FeedType & inputs, const std::vector< Output > & fetch_outputs, const std::vector< Operation > & run_outputs, std::vector< Tensor > *outputs, RunMetadata *run_metadata) const
Use run_options to turn on performance profiling.

Public types

FeedType

std::unordered_map< Output, Input::Initializer, OutputHash > FeedType

A data type to represent feeds to a Run call.

This is a map of Output objects returned by op-constructors to the value to feed them with. See Input::Initializer for details on what can be used as feed values.

Public functions

ClientSession

 ClientSession(
  const Scope & scope,
  const string & target
)

Create a new session to evaluate the graph contained in scope by connecting to the TensorFlow runtime specified by target.

ClientSession

 ClientSession(
  const Scope & scope
)

Same as above, but use the empty string ("") as the target specification.

ClientSession

 ClientSession(
  const Scope & scope,
  const SessionOptions & session_options
)

Create a new session, configuring it with session_options.

Run

Status Run(
  const std::vector< Output > & fetch_outputs,
  std::vector< Tensor > *outputs
) const 

Evaluate the tensors in fetch_outputs.

The values are returned as Tensor objects in outputs. The number and order of outputs will match fetch_outputs.

Run

Status Run(
  const FeedType & inputs,
  const std::vector< Output > & fetch_outputs,
  std::vector< Tensor > *outputs
) const 

Same as above, but use the mapping in inputs as feeds.

Run

Status Run(
  const FeedType & inputs,
  const std::vector< Output > & fetch_outputs,
  const std::vector< Operation > & run_outputs,
  std::vector< Tensor > *outputs
) const 

Same as above. Additionally runs the operations ins run_outputs.

Run

Status Run(
  const RunOptions & run_options,
  const FeedType & inputs,
  const std::vector< Output > & fetch_outputs,
  const std::vector< Operation > & run_outputs,
  std::vector< Tensor > *outputs,
  RunMetadata *run_metadata
) const 

Use run_options to turn on performance profiling.

run_metadata, if not null, is filled in with the profiling results.

© 2017 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/cc/class/tensorflow/client-session.html