tf.keras.ops.vectorized_map
Параллельное отображение function по оси 0 тензора(ов) elements.
tf.keras.ops.vectorized_map(
function, elements
)
Схематично, vectorized_map реализует следующее в случае единственного тензорного входного значения elements:
def vectorized_map(function, elements)
outputs = []
for e in elements:
outputs.append(function(e))
return stack(outputs)
В случае итерируемого набора тензоров elements, он реализует следующее:
def vectorized_map(function, elements)
batch_size = elements[0].shape[0]
outputs = []
for index in range(batch_size):
outputs.append(function([e[index] for e in elements]))
return np.stack(outputs)
В этом случае, ожидается, что function будет принимать на вход единственный список аргументов-тензоров.
© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/keras/ops/vectorized_map