小编Bug*_*soy的帖子

如何提高 CNN 模型的准确性

我建立了一个 cnn 模型,将面部情绪分类为快乐、悲伤、精力充沛和中性面孔。我使用 Vgg16 预训练模型并冻结所有层。经过 50 轮训练后,我的模型的测试精度为 0.65 ,验证损失约为 0.8 。

我的训练数据文件夹有 16000(4x4000) ,验证数据文件夹有 2000(4x500) ,测试数据文件夹有 4000(4x1000) rgb 图像。

1)您对提高模型精度有什么建议?

2)我尝试用我的模型进行一些预测,预测的类别始终相同。什么可能导致问题?

到目前为止我已经尝试过什么?

  1. 添加 dropout 层 (0.5)
  2. 在最后一层之前添加 Dense (256, relu)
  3. 打乱训练数据和验证数据。
  4. 将学习率降低到 1e-5

但我无法提高验证和测试准确性。

我的代码

train_src = "/content/drive/MyDrive/Affectnet/train_class/"
val_src = "/content/drive/MyDrive/Affectnet/val_class/"
test_src="/content/drive/MyDrive/Affectnet/test_classs/"

train_datagen = tensorflow.keras.preprocessing.image.ImageDataGenerator(
      rescale=1./255, 
      shear_range=0.2,
      zoom_range=0.2,
      horizontal_flip=True,
    
      )

train_generator = train_datagen.flow_from_directory(
        train_src,
        target_size=(224,224 ),
        batch_size=32,
        class_mode='categorical',
        shuffle=True
        )

validation_datagen = tensorflow.keras.preprocessing.image.ImageDataGenerator(
        rescale=1./255
        )

validation_generator = validation_datagen.flow_from_directory(
        val_src,
        target_size=(224, 224),
        batch_size=32,
        class_mode='categorical',
        shuffle=True
        )
conv_base = tensorflow.keras.applications.VGG16(weights='imagenet',
                  include_top=False,
                  input_shape=(224, …
Run Code Online (Sandbox Code Playgroud)

python conv-neural-network keras tensorflow vgg-net

4
推荐指数
1
解决办法
2599
查看次数

标签 统计

conv-neural-network ×1

keras ×1

python ×1

tensorflow ×1

vgg-net ×1