Link Search Menu Expand Document

ClientSession


tensorflow C++ API

tensorflow::ClientSession

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(},{c},&outputs);
if(!s.ok()){...}

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 scopeby 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 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.

~ClientSession

~ClientSession()

ClientSession block

Source link :https://github.com/EXPNUNI/enuSpaceTensorflow/blob/master/enuSpaceTensorflow/tf_core.cpp

Argument:

  • Scope scope : A Scope object (A scope is generated automatically each page. A scope is not connected.)
  • Inputs FeedType: A data type to represent feeds to a Run call. This is a map ofOutputobjects returned by op-constructors to the value to feed them with. SeeInput::Initializerfor details on what can be used as feed values.
  • const std::vector<Output>& run(fetch_outputs) : Evaluate the tensors infetch_outputs. The values are returned asTensorobjects inoutputs. The number and order ofoutputswill matchfetch_outputs.
  • const std::vector<Operation>& run(run_outputs): Same as above. Additionally runs the operations ins run_outputs.

Using Method