简体   繁体   English

Keras NN中的恒定精度/损失

[英]Constant Accuracy/Loss in Keras NN

I am learning deep learning and was implementing the titanic challenge on kaggle. 我正在学习深度学习,并在kaggle上实施了巨大的挑战。

In Preprocessing,I have dropped the Pid,name,ticket and cabin columns.I have replaced the empty values in Fare and Age columns by adding the respective means. 在“预处理”中,我删除了“价格”,“名称”,“机票”和“客舱”列。我通过添加相应的方法替换了“票价”和“年龄”列中的空值。 I have one hot encoded sex, Pclass(passenger class) and Embarked Port. 我有一个热门编码性爱,Pclass(乘客舱)和登船港。 Added an alone column to determine if the passenger was traveling alone or not(From sibling and parents count). 添加了一个单独的列来确定乘客是否独自旅行(由同胞和父母计算)。 Finally I used scikit's MinMaxScalar. 最后,我使用了scikit的MinMaxScalar。

Here is the keras model used. 这是使用的keras模型。

model = Sequential()
model.add(Dense(32, input_dim=13, activation="relu"))
model.add(Dense(64, activation="relu"))
model.add(Dense(128, activation="relu"))
model.add(Dense(256, activation="relu"))
model.add(Dropout(0.3))
model.add(Dense(512, activation="relu"))
model.add(Dense(1024, activation="relu"))
model.add(Dense(512, activation="relu"))
model.add(Dropout(0.3))
model.add(Dense(1024, activation="relu"))
model.add(Dense(2048, activation="relu"))
model.add(Dense(1024, activation="relu"))
model.add(Dropout(0.3))
model.add(Dense(512, activation="relu"))
model.add(Dense(1024, activation="relu"))
model.add(Dense(512, activation="relu"))
model.add(Dropout(0.3))
model.add(Dense(256, activation="relu"))
model.add(Dense(128, activation="relu"))
model.add(Dense(64, activation="relu"))
model.add(Dense(32, activation="relu"))
model.add(Dropout(0.3))
model.add(Dense(1, activation="sigmoid"))
model.compile(optimizer="Adam", loss='binary_crossentropy', metrics=["binary_accuracy"])

The val_binary_accuracy is a constant 0.6425 throughout the process 整个过程中val_binary_accuracy为常数0.6425

This is common with "relu". 这与“ relu”很常见。

"Relu" has a "constant zero" region. “ Relu”具有“恒定零”区域。 If any of the layer happens to fall entirely in this region, your model is dead. 如果任何一层恰好完全落入该区域,则您的模型已失效。

You can try one of these: 您可以尝试以下方法之一:

  • Create the model again (if you have a random seed, change the seed) 再次创建模型(如果您有随机种子,请更改种子)
  • Reduce the learning rate (but you don't seem to be using a really big one) 降低学习速度(但您似乎并没有使用太大的东西)
  • Use different activations ('tanh', 'sigmoid', etc.) 使用不同的激活(“ tanh”,“ Sigmoid”等)
  • Use BatchNormalization after the layer and before relu . 使用BatchNormalization层之后和之前relu

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM