tensorflow::ClientSession

#include <client_session.h>

ClientSessionオブジェクトを使用すると、呼び出し元はC++ APIで構築されたTensorFlowグラフの評価を制御できます。

まとめ

例:

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()) { ... }  

コンストラクターとデストラクタ

ClientSession (const Scope & scope, const string & target)
targetで指定された TensorFlow ランタイムに接続して、 scopeに含まれるグラフを評価するための新しいセッションを作成します。
ClientSession (const Scope & scope)
上記と同様ですが、ターゲット指定として空文字列("")を使用します。
ClientSession (const Scope & scope, const SessionOptions & session_options)
session_optionsを使用して新しいセッションを設定します。
~ClientSession ()

公開型

CallableHandle typedef
int64
ClientSession::MakeCallable()で作成されたサブグラフへのハンドル。
FeedType typedef
std::unordered_map< Output , Input::Initializer , OutputHash >
Run呼び出しへのフィードを表すデータ型。

公的機能

MakeCallable (const CallableOptions & callable_options, CallableHandle *out_handle)
callable_optionsで定義されたサブグラフを呼び出すためのhandleを作成します。
ReleaseCallable ( CallableHandle handle)
このセッションで指定されたhandleに関連付けられているリソースを解放します。
Run (const std::vector< Output > & fetch_outputs, std::vector< Tensor > *outputs) const
fetch_outputs内のテンソルを評価します。
Run (const FeedType & inputs, const std::vector< Output > & fetch_outputs, std::vector< Tensor > *outputs) const
上記と同様ですが、 inputsのマッピングをフィードとして使用します。
Run (const FeedType & inputs, const std::vector< Output > & fetch_outputs, const std::vector< Operation > & run_outputs, std::vector< Tensor > *outputs) const
上記と同じです。さらに、 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
パフォーマンスプロファイリングを有効にするには、 run_options使用してください。
RunCallable ( CallableHandle handle, const std::vector< Tensor > & feed_tensors, std::vector< Tensor > *fetch_tensors, RunMetadata *run_metadata)
指定されたオプションと入力テンソルを使用して、 handleで指定された名前のサブグラフを呼び出します。
RunCallable ( CallableHandle handle, const std::vector< Tensor > & feed_tensors, std::vector< Tensor > *fetch_tensors, RunMetadata *run_metadata, const thread::ThreadPoolOptions & options)
指定されたオプションと入力テンソルを使用して、 handleで指定された名前のサブグラフを呼び出します。

公開型

呼び出し可能なハンドル

int64 CallableHandle

ClientSession::MakeCallable()で作成されたサブグラフへのハンドル。

フィードタイプ

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

Run呼び出しへのフィードを表すデータ型。

これは、opコンストラクタによって返されるOutputオブジェクトと、それらに入力する値とのマップです。入力値として使用できるものについては、 Input::Initializer参照してください。

公的機能

クライアントセッション

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

targetで指定された TensorFlow ランタイムに接続して、 scopeに含まれるグラフを評価するための新しいセッションを作成します。

クライアントセッション

 ClientSession(
  const Scope & scope
)

上記と同様ですが、ターゲット指定として空文字列("")を使用します。

クライアントセッション

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

session_optionsを使用して新しいセッションを設定します。

呼び出し可能

Status MakeCallable(
  const CallableOptions & callable_options,
  CallableHandle *out_handle
)

callable_optionsで定義されたサブグラフを呼び出すためのhandleを作成します。

注:このAPIはまだ実験段階であり、変更される可能性があります。

ReleaseCallable

Status ReleaseCallable(
  CallableHandle handle
)

このセッションで指定されたhandleに関連付けられているリソースを解放します。

注:このAPIはまだ実験段階であり、変更される可能性があります。

走る

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

fetch_outputs内のテンソルを評価します。

値は、 outputsとしてTensorオブジェクトとして返されます。 outputsの数と順序は、 fetch_outputsと一致します。

走る

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

上記と同様ですが、 inputsのマッピングをフィードとして使用します。

走る

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

上記と同じです。さらに、 run_outputsの操作を実行します。

走る

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 

パフォーマンスプロファイリングを有効にするには、 run_options使用してください。

run_metadata 、null でない場合、プロファイリング結果が格納されます。

実行可能

Status RunCallable(
  CallableHandle handle,
  const std::vector< Tensor > & feed_tensors,
  std::vector< Tensor > *fetch_tensors,
  RunMetadata *run_metadata
)

指定されたオプションと入力テンソルを使用して、 handleで指定された名前のサブグラフを呼び出します。

feed_tensors内のテンソルの順序はCallableOptions::feed()内の名前の順序と一致する必要があります。また、 fetch_tensors内のテンソルの順序は、このサブグラフが作成されたときのCallableOptions::fetch()内の名前の順序と一致します。注: この API はまだ実験段階であり、変更される可能性があります。

実行可能

Status RunCallable(
  CallableHandle handle,
  const std::vector< Tensor > & feed_tensors,
  std::vector< Tensor > *fetch_tensors,
  RunMetadata *run_metadata,
  const thread::ThreadPoolOptions & options
)

指定されたオプションと入力テンソルを使用して、 handleで指定された名前のサブグラフを呼び出します。

feed_tensors内のテンソルの順序はCallableOptions::feed()内の名前の順序と一致する必要があります。また、 fetch_tensors内のテンソルの順序は、このサブグラフが作成されたときのCallableOptions::fetch()内の名前の順序と一致します。注: この API はまだ実験段階であり、変更される可能性があります。

~クライアントセッション

 ~ClientSession()