标签: python arrays tensorflow
如何将矩阵从3-D更改为4-D。更具体地说,如何将形状为A的矩阵(x, y, z)转换为形状为B的矩阵(1,x,y,z)?
A
(x, y, z)
B
(1,x,y,z)
例如元素A[7,3,5] == B[1,7,3,5]
A[7,3,5] == B[1,7,3,5]
答案 0 :(得分:2)
tensorflow.expand_dims函数应该是完美的匹配:
tensorflow.expand_dims
new_matrix = tf.expand_dims(old_matrix, axis=0)