This commit is contained in:
jh 2021-03-12 18:07:27 -08:00
commit 0225a29832

View file

@ -19,6 +19,7 @@ class MsSsim(nn.LayerBase):
# Transpose images from NCHW to NHWC # Transpose images from NCHW to NHWC
y_true_t = tf.transpose(y_true, [0, 2, 3, 1]) y_true_t = tf.transpose(y_true, [0, 2, 3, 1])
y_pred_t = tf.transpose(y_pred, [0, 2, 3, 1]) y_pred_t = tf.transpose(y_pred, [0, 2, 3, 1])
with tf.device('/CPU:0'):
loss = tf.image.ssim_multiscale(y_true_t, y_pred_t, max_val, power_factors=self.power_factors) loss = tf.image.ssim_multiscale(y_true_t, y_pred_t, max_val, power_factors=self.power_factors)
return (1.0 - loss) / 2.0 return (1.0 - loss) / 2.0