TensorFlow - Tensor Reshape -
i'm using tensorflow , have following matrix:
u2 = tf.constant([[1,3],[0,1],[1,0]],dtype=tf.float32) [[ 1. 3.] [ 0. 1.] [ 1. 0.]]
what's easiest way reshape matrix results in tensor:
tf.constant([[[1,1],[0,0],[1,1]],[[3,3],[1,1],[0,0]]],dtype=tf.float32) [[[ 1. 1.] [ 0. 0.] [ 1. 1.]] [[ 3. 3.] [ 1. 1.] [ 0. 0.]]]
this 1 quick way create first submatrix using tensorflow api:
u2 = tf.constant([[1,3],[0,1],[1,0]],dtype=tf.float32) first_col = tf.unpack(u2, axis=1)[0] repeated_cols = tf.tile(first_col, [2]) repeated_cols = tf.reshape(repeated_cols, [3,2])
which create
[[ 1. 1.] [ 0. 0.] [ 1. 1.]]
Comments
Post a Comment