我们怎样才能在输出中添加额外尺寸的tf.tile?

时间:2018-03-26 15:02:16

标签: tensorflow

假设我有pthread_cancel,那么创建SELECT u.user_id, u.user_name, COALESCE((SELECT SUM(nb_hour_doc) FROM T1 WHERE user_id = u.user_id GROUP BY user_id) + (SELECT SUM(nb_hour_interv) FROM T2 WHERE user_id = u.user_id GROUP BY user_id), 0) AS hours FROM users u SELECT u.user_id, u.user_name, COALESCE((SELECT SUM(nb_doc) FROM T1 WHERE user_id = u.user_id GROUP BY user_id) + (SELECT SUM(nb_interv) FROM T2 WHERE user_id = u.user_id GROUP BY user_id), 0) AS hours FROM users u SELECT z.project, SUM(z.hour) FROM (SELECT project, nb_hour_doc as hour FROM T1 UNION ALL SELECT project, nb_hour_interv AS hour FROM T2 ) as z GROUP BY z.project 张量的最佳方法是什么,tensor = tf.constant([1, 2])

用例类似于[[tensor, tensor], [tensor, tensor]]。但是,[[[1, 2], [1, 2]], [[1, 2], [1, 2]]]不会创建额外的维度。

1 个答案:

答案 0 :(得分:2)

在使用tile之前重新定形张量,此示例演示:

import tensorflow as tf
sess = tf.InteractiveSession()

tensor = tf.constant([1, 2])
tensor_reshaped = tf.reshape(tensor, (1,1,2))
tf.tile(tensor_reshaped, [2, 2, 1]).eval()

Out[22]: 
array([[[1, 2],
        [1, 2]],
       [[1, 2],
        [1, 2]]], dtype=int32)