【发布时间】:2021-08-16 17:35:20
【问题描述】:
目前,我正在尝试在 VGG-16 模型上训练数据集。问题是精度没有太大变化,但它并没有固定在一个固定的精度上。情节图如下所示。有什么建议为什么会发生这种情况?
我已经按照几个指南来解决这个关于准确性卡住的问题,但它们不起作用。
编辑:
200 个纪元
50 个具有 Imagenet 权重的 Epochs
代码
模型的输入大小为 600 张 224x224x3 的图像。此外,两个标签狗和猫(0,1)。
属性
imageSize = (224,224,3)
epochs = 25
batch_size = 32
型号
from keras.applications.vgg16 import VGG16
vgg = VGG16(input_shape=imageSize,weights=None,include_top=False)
x = Flatten()(vgg.output)
prediction = Dense(1,activation='sigmoid')(x)
model = Model(inputs=vgg.input,outputs=prediction)
model.compile(loss='binary_crossentropy', optimizer='adam',metrics=['accuracy'])
图像生成器
from keras.applications.vgg16 import preprocess_input
from keras.preprocessing import image
from keras.preprocessing.image import ImageDataGenerator
imgGen = ImageDataGenerator(rotation_range=20,
width_shift_range=0.1,
height_shift_range=0.1,
shear_range=0.1,
zoom_range=0.2,
horizontal_flip=True,
vertical_flip=True,
preprocessing_function = preprocess_input)
拟合模型
r = model.fit_generator(imgGen.flow(trainX, trainY, batch_size=batch_size),
validation_data = imgGen.flow(testX, testY, batch_size=batch_size),
epochs=epochs,
steps_per_epoch=len(trainX)//batch_size,
validation_steps=len(testX)//batch_size,
verbose = 1,
)
【问题讨论】:
标签: python tensorflow keras deep-learning