zl程序教程

您现在的位置是:首页 >  其它

当前栏目

tf.reshape 和 tf.transpose 用法

用法 TF reshape
2023-09-14 09:15:50 时间
import tensorflow as tf
x= tf.constant(
                 [[2,3],[4,5],[6,7]],
             
                 tf.int32)
print(x.numpy())
[[2 3]
 [4 5]
 [6 7]]
x1=tf.reshape(x, shape = (tf.shape(x)[1], tf.shape(x)[0]))
print(x1.numpy())
[[2 3 4]
 [5 6 7]]
x2=tf.transpose(x1)
print(x2.numpy())
[[2 5]
 [3 6]
 [4 7]]