问题描述
原点张量:
a = tf.constant([[1,2,3],[4,5,6],[7,8,9]])
我想要这样的张量:
result = [[1,[1,9],9]]
使用 tile api 似乎不合适,有人可以帮忙吗?
解决方法
使用tf.repeat
。
tf.repeat(a,repeats=3,axis=0)
<tf.Tensor: shape=(9,3),dtype=int32,numpy=
array([[1,2,3],[1,[4,5,6],[7,8,9],9]])>