2

I have been using tensorflow with python3 support. There is line in my code which throws me an error.

The error here :

return -10. * np.log10(K.mean(K.square(y_pred - y_true)))

AttributeError: 'Tensor' object has no attribute 'log10'

Bellerofont
  • 1,081
  • 18
  • 17
  • 16

1 Answers1

4

you can do like this:

return 10.0 * K.log(1.0 / (K.mean(K.square(y_pred - y_true)))) / K.log(10.0)
Ansle liu
  • 41
  • 1
  • 2
    This works great for me, but I think you meant `-10`. Can you elaborate on why the prior code doesn't work in Tensorflow? I'm assuming it has something to do with numpy not knowing how to handle the tensorflow result. – Chris Foster Mar 11 '17 at 04:43