alexlee-gk / lpips-tensorflow

Tensorflow port for the Learned Perceptual Image Patch Similarity (LPIPS) metric.
BSD 2-Clause "Simplified" License
130 stars 30 forks source link

NCHW to NHWC clarification #2

Open cmatija opened 5 years ago

cmatija commented 5 years ago

Thank you very much for the great code. However, I am confused about the conversion from NCHW to NHWC in lines 52/53 of lpips_tf.py. Shouldn't the correct permutation vector be [0,2,3,1] as opposed to [0,3,1,2]? I have noticed that using [0,2,3,1] I get an error later, so I guess it is the correct vector after all, however, I can't wrap my head around as to how, to achieve permutation from NCHW to NHWC, any other permutation vector than [0,2,3,1] is used. May I ask for some clarification on this matter?

alexlee-gk commented 5 years ago

You are indeed correct that the permutation should be [0,2,3,1] to convert from NCHW to NHWC. The mistake was in the comment—it actually does a NHWC to NCHW conversion, and not the other way around. I fixed the comment to reflect this. Thanks for pointing it out!