Ich habe R
als 2D-Rotationsmatrizen der Form (N,2,2)
. Nun möchte ich jede Matrix auf 3D-Rotationsmatrizen erweitern, d. H. Nullen in jede [:,:2,:2]
setzen und 1
auf [:,2,2]
setzen.Wie puffern mehrere Tensoren mit einem auf Hauptdiagonale und Nullen an anderer Stelle?
Wie geht das im Tensorflow?
UPDATE
ich auf diese Weise versucht,
R = tf.get_variable(name='R', shape=np.shape(R_value), dtype=tf.float64,
initializer=tf.constant_initializer(R_value))
eye = tf.eye(np.shape(R_value)[1]+1)
right_column = eye[:2,2]
bottom_row = eye[2,:]
R = tf.concat([R, right_column], 3)
R = tf.concat([R, bottom_row], 2)
aber gescheitert, weil concat
nicht Rundfunk macht ...
UPDATE 2
ich explizit gemacht Broadcasting und auch feste falsche Indizes in concat
Anrufe:
R = tf.get_variable(name='R', shape=np.shape(R_value), dtype=tf.float64,
initializer=tf.constant_initializer(R_value))
eye = tf.eye(np.shape(R_value)[1]+1, dtype=tf.float64)
right_column = eye[:2,2]
right_column = tf.expand_dims(right_column, 0)
right_column = tf.expand_dims(right_column, 2)
right_column = tf.tile(right_column, (np.shape(R_value)[0], 1, 1))
bottom_row = eye[2,:]
bottom_row = tf.expand_dims(bottom_row, 0)
bottom_row = tf.expand_dims(bottom_row, 0)
bottom_row = tf.tile(bottom_row, (np.shape(R_value)[0], 1, 1))
R = tf.concat([R, right_column], 2)
R = tf.concat([R, bottom_row], 1)
Die Lösungen sieht ziemlich komplex. Gibt es einfachere?