简体   繁体   English

在 Keras 中实现神经网络的准确度非常低

[英]Getting a very low accuracy on implementing Neural Network in Keras

I am trying to implement ANN on a Cifar-10 dataset using keras but for some reason I dont know I am getting only 10% accuracy?我正在尝试使用 keras 在 Cifar-10 数据集上实现 ANN,但由于某种原因,我不知道我的准确率只有 10%?

I have used 5 hidden layers iwth 8,16,32,64,128 neurons respectively.我使用了 5 个隐藏层,分别有 8、16、32、64、128 个神经元。

This is the link to the jupyter notebook 这是 jupyter 笔记本的链接

model = Sequential()
model.add(Dense(units = 8,activation = 'sigmoid' , input_dim = X.shape[1]))
model.add(Dense(units = 16 , activation = 'sigmoid'))
model.add(Dense(units = 32 , activation = 'sigmoid'))
model.add(Dense(units = 64 , activation = 'sigmoid'))
model.add(Dense(units = 128 , activation = 'sigmoid'))
model.add(Dense(units = 10 , activation = 'softmax'))

model.compile(loss = 'categorical_crossentropy' , optimizer = 'adam' , metrics = ['accuracy'])

model.fit(x_train,y_train,epochs = 1000, batch_size = 500 )

That's very normal accuracy for a such network like this.对于这样的网络来说,这是非常正常的准确性。 You only have Dense layers which is not sufficient for this dataset.您只有密集层,这对于该数据集来说是不够的。 Cifar-10 is an image dataset, so: Cifar-10 是一个图像数据集,因此:

  • Consider using CNNs考虑使用 CNN

  • Use 'relu' activation instead of sigmoid.使用“relu”激活而不是 sigmoid。

  • Try to use image augmentation尝试使用图像增强

  • To avoid overfitting do not forget to regularize your model.为避免过度拟合,不要忘记正则化您的 model。

Also batch size of 500 is high. 500的批量大小也很高。 Consider using 32 - 64 - 128.考虑使用 32 - 64 - 128。

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

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