Spec-Zone.ru › TensorFlow C++ 2.3

tensorflow::ops::ParallelDynamicStitch

#include <data_flow_ops.h>

Перемешивание значений из data тензоров в один тензор.

Summary

Строит объединенный тензор таким образом, что

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 должна быть постоянной относительно i. То есть, должно быть выполнено условие data[i].shape = indices[i].shape + constant. В терминах этого constant, форма выходного тензора имеет вид

merged.shape = [max(indices)] + constant

Значения могут быть объединены параллельно, поэтому, если индекс присутствует как в indices[m][i], так и в indices[n][j], результат может быть недействительным. Это отличается от обычного оператора DynamicStitch, который определяет поведение в этом случае.

Например:

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.

Аргументы:

  • scope: Объект Scope

Возвращаемое значение:

  • Output: Объединённый тензор.
Конструкторы и деструкторы
ParallelDynamicStitch(const ::tensorflow::Scope & scope, ::tensorflow::InputList indices, ::tensorflow::InputList data)
Публичные атрибуты
merged
::tensorflow::Output
operation
Operation
Публичные функции
node() const
::tensorflow::Node *
operator::tensorflow::Input() const
operator::tensorflow::Output() const

Публичные атрибуты

merged

::tensorflow::Output merged

operation

Operation operation

Публичные функции

ParallelDynamicStitch

 ParallelDynamicStitch(
  const ::tensorflow::Scope & scope,
  ::tensorflow::InputList indices,
  ::tensorflow::InputList data
)

node

::tensorflow::Node * node() const 

operator::tensorflow::Input

operator::tensorflow::Input() const 

operator::tensorflow::Output

operator::tensorflow::Output() const 

© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/parallel-dynamic-stitch

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API