dòng chảy căng:: ôi:: Song SongNăng ĐộngKhâu
#include <data_flow_ops.h>
xen kẽ các giá trị từ tensor data
vào một tensor duy nhất.
Bản tóm tắt
Xây dựng một tensor hợp nhất sao cho
merged[indices[m][i, ..., j], ...] = data[m][i, ..., j, ...]
Ví dụ: nếu mỗi indices[m]
là vô hướng hoặc vectơ, chúng ta có
# Scalar indices:
merged[indices[m], ...] = data[m][...]
# Vector indices:
merged[indices[m][i], ...] = data[m][i, ...]
Mỗi data[i].shape
phải bắt đầu bằng indices[i].shape
và phần còn lại của data[i].shape
phải không đổi wrt i
. Nghĩa là, chúng ta phải có data[i].shape = indices[i].shape + constant
. Xét về constant
này, hình dạng đầu ra là
merged.shape = [max(indices)] + constant
Các giá trị có thể được hợp nhất song song, vì vậy nếu một chỉ mục xuất hiện trong cả hai indices[m][i]
và indices[n][j]
thì kết quả có thể không hợp lệ. Điều này khác với toán tử DynamicStitch thông thường xác định hành vi trong trường hợp đó.
Ví dụ:
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]]
Phương pháp này có thể được sử dụng để hợp nhất các phân vùng được tạo bởi dynamic_partition
như minh họa trong ví dụ sau:
# 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.

Lập luận:
- phạm vi: Một đối tượng Phạm vi
Trả về:
-
Output
: Tenxơ đã hợp nhất.
Hàm tạo và hàm hủy | |
---|---|
ParallelDynamicStitch (const :: tensorflow::Scope & scope, :: tensorflow::InputList indices, :: tensorflow::InputList data) |
Chức năng công cộng | |
---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const |
Thuộc tính công khai
sáp nhập
::tensorflow::Output merged
hoạt động
Operation operation
Chức năng công cộng
Song SongNăng ĐộngKhâu
ParallelDynamicStitch(
const ::tensorflow::Scope & scope,
::tensorflow::InputList indices,
::tensorflow::InputList data
)
nút
::tensorflow::Node * node() const
toán tử::tenorflow::Đầu vào
operator::tensorflow::Input() const
toán tử::tenorflow::Đầu ra
operator::tensorflow::Output() const