Why is the accuracy for my Keras model always 0 when training?

后端 未结 4 888
粉色の甜心
粉色の甜心 2020-12-23 09:36

I\'m pretty new to keras I have built a simple network to try:

import numpy as np;

from keras.models import Sequential;
from keras.layers import Dense,Activ         


        
4条回答
  •  春和景丽
    2020-12-23 09:57

    Try this one.

    while trying to solve the Titanic problem from kaggle, I forgot to fill the missing data from the Dataframe, because of which the missing data was filled with "nan".

    The model threw a similar output

    #------------------------------------------------------
    
    Epoch 1/50
    
    891/891 [==============================] - 3s 3ms/step - loss: 9.8239 - acc: 0.0000e+00
    
    Epoch 2/50
    
    891/891 [==============================] - 1s 2ms/step - loss: 9.8231 - acc: 0.0000e+00
    
    Epoch 3/50
    
    891/891 [==============================] - 1s 1ms/step - loss: 9.8231 - acc: 0.0000e+00
    
    Epoch 4/50
    
    891/891 [==============================] - 1s 1ms/step - loss: 9.8231 - acc: 0.0000e+00
    
    Epoch 5/50
    
    891/891 [==============================] - 1s 1ms/step - loss: 9.8231 - acc: 0.0000e+00
    
    #------------------------------------------------------
    

    Make sure you prepare your data before feeding it to the model.

    In my case I had to do the following changes

    +++++++++++++++++++++++++++++++++++
    
    dataset[['Age']] = dataset[['Age']].fillna(value=dataset[['Age']].mean())
    
    dataset[['Fare']] = dataset[['Fare']].fillna(value=dataset[['Fare']].mean())
    
    dataset[['Embarked']] = dataset[['Embarked']].fillna(value=dataset['Embarked'].value_counts().idxmax())
    

提交回复
热议问题