■ Working Draft/◎ 에러코드 일기장
[Numpy 에러] TypeError: only size-1 arrays can be converted to Python scalars
dhwiii
2021. 5. 19. 18:58
TypeError: only size-1 arrays can be converted to Python scalars
일반적으로 사용하는 math 함수와 numpy array의 형태를 가진 변수와 호환이 잘 되지 않아서 에러가 발생한 것 같다.
mse = tf.reduce_mean((float)((fake_hr - imgs_hr) ** 2))
#변경 전
PSNR = 10 * math.log10((255 ** 2) / mse)
#변경 후
PSNR = 10 * np.math.log10((255 ** 2) / mse)
np.math를 사용해 보도록 하자