2024-09-30 04:27:44 发布
网友
我有5个波段的图像数据库:
RGB + alpha (a) + topography (t).
我知道如何反转RGB(没有其他波段)以获得BGR:tf.reverse(image_patch, axis = [-1])
tf.reverse(image_patch, axis = [-1])
有image_patch:Tensor("Sub:0", shape=(256, 256, 5), dtype=float32)
image_patch
Tensor("Sub:0", shape=(256, 256, 5), dtype=float32)
但是我怎样才能改变这个张量的维数,按照这个顺序:BGRat
BGRat
您可以使用^{}方法
示例代码
import tensorflow as tf # Parameters rows = 2 shift = 3 a = tf.placeholder(dtype=tf.int64, shape=(rows, 5)) b = tf.reverse_sequence(a, seq_lengths=[shift] * rows, batch_dim = 0, seq_dim=1) sess = tf.Session() print(sess.run(b, feed_dict={a: [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]}))
结果
# a - sample input [[1 2 3 4 5] [1 2 3 4 5]] # b - shifted columns [[3 2 1 4 5] [3 2 1 4 5]]
您可以使用^{} 方法
示例代码
结果
相关问题 更多 >
编程相关推荐