im1 = tf.image.convert_image_dtype(np.random.randn(64,64,3), tf.float32)
im2 = tf.image.convert_image_dtype(np.random.randn(64,64,3), tf.float32)
psnr = tf.image.psnr(tf.expand_dims(im1[:,:,0], 2),
tf.expand_dims(im2[:,:,0], 2), max_val=255)
with tf.Session() as sess:
print (sess.run(psnr))
Получите первый канал, используя im1[:,:,0]
, и измените его до h x w x 1
, добавив один канал, используя expand_dims