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::vectoroutputs; 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 | typedefint64ClientSession::MakeCallable() 사용하여 생성된 서브그래프에 대한 핸들입니다. |
FeedType | typedefstd::unordered_map< Output , Input::Initializer , OutputHash > Run 호출에 대한 피드를 나타내는 데이터 유형입니다. |
공공 기능 | |
|---|---|
MakeCallable (const CallableOptions & callable_options, CallableHandle *out_handle) | Statuscallable_options 로 정의된 서브그래프를 호출하기 위한 handle 생성합니다. |
ReleaseCallable ( CallableHandle handle) | Status 이 세션에서 지정된 handle 과 관련된 리소스를 해제합니다. |
Run (const std::vector< Output > & fetch_outputs, std::vector< Tensor > *outputs) const | Statusfetch_outputs 에 있는 텐서를 평가합니다. |
Run (const FeedType & inputs, const std::vector< Output > & fetch_outputs, std::vector< Tensor > *outputs) const | Status 위와 동일하지만, inputs 값으로 매핑을 피드로 사용합니다. |
Run (const FeedType & inputs, const std::vector< Output > & fetch_outputs, const std::vector< Operation > & run_outputs, std::vector< Tensor > *outputs) const | Status 위와 동일합니다. 추가적으로 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 | Statusrun_options 사용하여 성능 프로파일링을 활성화하세요. |
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 thread::ThreadPoolOptions & threadpool_options) const | Status 위와 동일합니다. |
RunCallable ( CallableHandle handle, const std::vector< Tensor > & feed_tensors, std::vector< Tensor > *fetch_tensors, RunMetadata *run_metadata) | Status 지정된 옵션과 입력 텐서를 사용하여 handle 로 명명된 서브그래프를 호출합니다. |
RunCallable ( CallableHandle handle, const std::vector< Tensor > & feed_tensors, std::vector< Tensor > *fetch_tensors, RunMetadata *run_metadata, const thread::ThreadPoolOptions & options) | Status 지정된 옵션과 입력 텐서를 사용하여 handle 로 명명된 서브그래프를 호출합니다. |
공개 유형
사료 종류
std::unordered_map< Output, Input::Initializer, OutputHash > FeedType
Run 호출에 대한 피드를 나타내는 데이터 유형입니다.
이 맵은 연산 생성자가 반환하는 Output 객체와 해당 객체에 입력할 값 사이의 관계를 나타냅니다. 입력 값으로 사용할 수 있는 항목에 대한 자세한 내용은 Input::Initializer 참조하십시오.
공공 기능
클라이언트 세션
ClientSession( const Scope & scope, const string & target )
target 에 지정된 TensorFlow 런타임에 연결하여 scope 에 포함된 그래프를 평가하기 위한 새 세션을 생성합니다.
클라이언트 세션
ClientSession( const Scope & scope, const SessionOptions & session_options )
session_options 사용하여 새 세션을 구성합니다.
MakeCallable
Status MakeCallable( const CallableOptions & callable_options, CallableHandle *out_handle )
callable_options 로 정의된 서브그래프를 호출하기 위한 handle 생성합니다.
참고: 이 API는 아직 실험 단계이며 변경될 수 있습니다.
릴리스콜러블
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 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 thread::ThreadPoolOptions & threadpool_options ) const
위와 동일합니다.
또한 ThreadPoolOptions를 통해 사용자가 사용자 지정 스레드 풀 구현을 제공할 수 있습니다.
RunCallable
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는 아직 실험 단계이며 변경될 수 있습니다.
RunCallable
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()