텐서플로우:: 작전:: 다이나믹스티치
#include <data_flow_ops.h>
data
텐서의 값을 단일 텐서에 인터리브합니다.
요약
다음과 같이 병합된 텐서를 구축합니다.
merged[indices[m][i, ..., j], ...] = data[m][i, ..., j, ...]
예를 들어, 각 indices[m]
가 스칼라 또는 벡터인 경우 다음과 같습니다.
# Scalar indices:
merged[indices[m], ...] = data[m][...]
# Vector indices:
merged[indices[m][i], ...] = data[m][i, ...]
각 data[i].shape
해당 indices[i].shape
로 시작해야 하며 나머지 data[i].shape
wrt i
상수여야 합니다. 즉, data[i].shape = indices[i].shape + constant
가 있어야 합니다. 이 constant
의 관점에서 출력 형태는 다음과 같습니다.
merged.shape = [max(indices)] + constant
값은 순서대로 병합되므로 (m,i) < (n,j)
에 대해 인덱스가 indices[m][i]
및 indices[n][j]
모두에 나타나면 슬라이스 data[n][j]
는 병합된 결과에 나타납니다. 이 보장이 필요하지 않은 경우 ParallelDynamicStitch는 일부 장치에서 더 나은 성능을 발휘할 수 있습니다.
예를 들어:
indices[0] = 6
indices[1] = [4, 1]
indices[2] = [[5, 2], [0, 3]]
data[0] = [61, 62]
data[1] = [[41, 42], [11, 12]]
data[2] = [[[51, 52], [21, 22]], [[1, 2], [31, 32]]]
merged = [[1, 2], [11, 12], [21, 22], [31, 32], [41, 42],
[51, 52], [61, 62]]
이 방법은 다음 예에 설명된 것처럼 dynamic_partition
으로 생성된 파티션을 병합하는 데 사용할 수 있습니다.
# Apply function (increments x_i) on elements for which a certain condition
# apply (x_i != -1 in this example).
x=tf.constant([0.1, -1., 5.2, 4.3, -1., 7.4])
condition_mask=tf.not_equal(x,tf.constant(-1.))
partitioned_data = tf.dynamic_partition(
x, tf.cast(condition_mask, tf.int32) , 2)
partitioned_data[1] = partitioned_data[1] + 1.0
condition_indices = tf.dynamic_partition(
tf.range(tf.shape(x)[0]), tf.cast(condition_mask, tf.int32) , 2)
x = tf.dynamic_stitch(condition_indices, partitioned_data)
# Here x=[1.1, -1., 6.2, 5.3, -1, 8.4], the -1. values remain
# unchanged.

인수:
- 범위: 범위 개체
보고:
-
Output
: 병합된 텐서.
생성자와 소멸자 | |
---|---|
DynamicStitch (const :: tensorflow::Scope & scope, :: tensorflow::InputList indices, :: tensorflow::InputList data) |
공공 기능 | |
---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const |
공개 속성
병합된
::tensorflow::Output merged
작업
Operation operation
공공 기능
다이나믹스티치
DynamicStitch(
const ::tensorflow::Scope & scope,
::tensorflow::InputList indices,
::tensorflow::InputList data
)
마디
::tensorflow::Node * node() const
연산자::텐서플로우::입력
operator::tensorflow::Input() const
연산자::텐서플로우::출력
operator::tensorflow::Output() const