📜  Python – tensorflow.dynamic_stitch()

📅  最后修改于: 2022-05-13 01:55:24.620000             🧑  作者: Mango

Python – tensorflow.dynamic_stitch()

TensorFlow 是由 Google 设计的开源Python库,用于开发机器学习模型和深度学习神经网络。

dynamic_stitch()用于将多个张量合并为单个张量。

示例 1:

Python3
# Importing the library
import tensorflow as tf
  
# Initializing the input
indices = [[0, 1, 5], [2, 4, 3, 6]]
data = [[1, 2, 3], [4, 5, 6, 7]]
  
# Printing the input
print('indices:', indices)
print('data: ', data)
  
# Calculating result
x = tf.dynamic_stitch(indices, data)
  
# Printing the result
print('x: ', x)


Python3
# Importing the library
import tensorflow as tf
  
# Initializing the input
indices = [[0, 1, 6], [5, 4, 3]]
data = [[1, 2, 3], [4, 5, 6]]
  
# Printing the input
print('indices:', indices)
print('data: ', data)
  
# Calculating result
x = tf.dynamic_stitch(indices, data)
  
# Printing the result
print('x: ', x)


输出:

indices: [[0, 1, 5], [2, 4, 3, 6]]
data:  [[1, 2, 3], [4, 5, 6, 7]]
x:  tf.Tensor([1 2 4 6 5 3 7], shape=(7, ), dtype=int32)

示例 2:

Python3

# Importing the library
import tensorflow as tf
  
# Initializing the input
indices = [[0, 1, 6], [5, 4, 3]]
data = [[1, 2, 3], [4, 5, 6]]
  
# Printing the input
print('indices:', indices)
print('data: ', data)
  
# Calculating result
x = tf.dynamic_stitch(indices, data)
  
# Printing the result
print('x: ', x)

输出:

indices: [[0, 1, 2], [5, 4, 3]]
data:  [[1, 2, 3], [4, 5, 6]]
x:  tf.Tensor([1 2 3 6 5 4], shape=(6, ), dtype=int32)