TensorFlow: AttributeError: 'Tensor' objec

2019-07-14 04:45发布

问题:

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:

you can do like this:

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