2
votes

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'

1
what is K? in K.mean and K.square? - Amitay Nachmani
I am using Keras (already installed) I have in my code.......from keras import backend as K - Surajit Saikia
what does K.mean returns? it seems it returns a tensor object and not a nummpy array - Amitay Nachmani
Yes, you are correct...actually i changed it to Theano backend and it started working :) - Surajit Saikia
I just ran into exactly the same issue, could you elaborate on your solution please? - tohoho

1 Answers

4
votes

you can do like this:

return 10.0 * K.log(1.0 / (K.mean(K.square(y_pred - y_true)))) / K.log(10.0)