tensorflow中list转换为tensor

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Arctic_Beacon/article/details/85119638

a = tf.reshape(b, [1, -1])

I don't know how many columes it can be, but I only want one row. Or

a = tf.reshape(b, [-1, 3])

I don't know how many rows it can be, but I  want 3 columes.

More examples for -1

>>> a = np.array([[1,2,3], [4,5,6]])
>>> np.reshape(a, (3,-1))       # the unspecified value is inferred to be 2
array([[1, 2],
       [3, 4],
       [5, 6]])
>>> a = np.arange(6).reshape((-1, 2))
>>> a
array([[0, 1],
       [2, 3],
       [4, 5]])

猜你喜欢

转载自blog.csdn.net/Arctic_Beacon/article/details/85119638