Zero accuracy training a neural network in Keras

前端 未结 5 626
别那么骄傲
别那么骄傲 2021-01-17 08:17

I train a Neural Network of Regression Problem in Keras. Why the output is only one Dimension, the accuracy in each Epoch always show acc: 0.0000e+00?

like this:

5条回答
  •  余生分开走
    2021-01-17 09:16

    Just a quick add-on to the excellent answers already posted.

    The following snippet is a custom metric that will display the average percentage difference between you NN's prediction and the actual value.

    def percentage_difference(y_true, y_pred):
        return K.mean(abs(y_pred/y_true - 1) * 100)
    

    to implement it into your metrics simply add it to the "metrics" option in your model compilation. I.e.

    model.compile(loss= 'mean_squared_error', 
    optimizer='Adam', metrics=['accuracy',percentage_difference])
    

提交回复
热议问题