使用ResNet50,验证准确性和损失不会改变

时间:2020-04-15 14:04:36

标签: python tensorflow keras resnet cnn

我正在尝试使用Python(ResNet50)中的keras进行图像识别。我尝试使用VGG16执行相同的任务,并且得到了类似以下的结果(对我来说似乎还可以): resultsVGG16。培训和验证准确性/损失功能在每个步骤中都在不断完善,因此网络必须学习。

但是,ResNet50的训练功能更好,而验证功能却没有改变:resultsResNet

我两次都使用相同的代码和数据,只是更改了模型。

那么ResNet50仅在训练数据上学习的原因是什么?

我的ResNet模型如下:

''''python

model = Sequential()
base_model = VGG16(weights='imagenet', include_top=False,input_shape= 
(image_size,image_size,3))
for layer in base_model.layers[:-4]:
    layer.trainable=False

model.add(base_model)
model.add(Flatten())
model.add(Dense(256, activation='relu'))
model.add(Dropout(0.4))
model.add(Dense(NUM_CLASSES, activation='softmax'))

VGG非常相似:

model = Sequential()
base_model = ResNet50(include_top=False, weights='imagenet', input_shape= 
(image_size,image_size,3))
for layer in base_model.layers[:-8]:
     layer.trainable=False

model.add(base_model)
model.add(Flatten())
model.add(Dense(256, activation='relu'))
model.add(Dropout(0.4))
model.add(Dense(NUM_CLASSES, activation='softmax'))

0 个答案:

没有答案