Skip to content Skip to sidebar Skip to footer

How Do I Prevent Loss: Nan While I'm Fitting My Keras Model?

Here is my code: model = Sequential() model.add(Dense(50, input_dim=33, init='uniform', activation='relu')) for u in range(3): #how to efficiently add more layers model.add(Den

Solution 1:

If you are using categorical_crossentropy as loss function then the last layer of the model should be softmax.

Here you are using sigmoid which has the chance of making all dimensions of output close to 0 which will result in loss to overflow and hence nan.

Post a Comment for "How Do I Prevent Loss: Nan While I'm Fitting My Keras Model?"