我有一个尺寸为N的张量,我想复制它以创建一个尺寸为NxD的张量,每列都是初始矢量。
谢谢
答案 0 :(得分:3)
您希望首先将张量扩展/重塑为N x 1
形状,然后在第二维中平铺D
次:
tensor_N_x_1 = tf.expand_dims(tensor, 1) # Expand by adding a dim in position 1
tensor_N_x_D = tf.tile(tensor_N_x_1, [1, D]) # Tile 1 time in the 1st dim, D times in the 2nd
文档: