Promise.all([ajaxCall1, ..., ajaxCallN]).then(responseArray => {})
Вы можете использовать tf.map_fn()
для достижения этого.
import tensorflow as tf
import numpy as np
input1 = [[[1,2], [3,4]], [[5,6], [7,8]], [[9,10], [11,12]]]
input2 = [0, 1, 1]
tf_input1 = tf.placeholder(shape=(None,2,2),dtype=tf.int32)
tf_input2 = tf.placeholder(shape=(None),dtype=tf.int32)
result = tf.map_fn(lambda x: x[0][:,x[1]], [tf_input1,tf_input2], dtype=tf.int32)
with tf.Session()as sess:
result = sess.run(result,feed_dict={tf_input1:np.array(input1)
,tf_input2:np.array(input2)})
print(result)
# print
[[ 1 3]
[ 6 8]
[10 12]]
Редактировать
tf.map_fn()
медленнее по сравнению с векторизованной операцией. Я добавил операцию умножения матриц.
# shape= (3,2,1)
result = tf.cast(tf.expand_dims(tf.one_hot(input2, 2),-1),tf.int32)
# shape= (3,2)
result = tf.squeeze(tf.matmul(tf_input1, result))