Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
微调模型中的Keras精度差异 背景_Keras - Fatal编程技术网

微调模型中的Keras精度差异 背景

微调模型中的Keras精度差异 背景,keras,Keras,在Keras中微调分类模型时,它打印了val\u acc:0.8456。用于微调 在微调、手动加载训练模型并预测估值集后,获得的精确度要低得多的0.28 以下代码用于估价: model = load_model(MODEL_PATH) ... img = kimage.load_img(img_path, target_size=target_size) x = kimage.img_to_array(img) x = np.expand_dims(x, axis=0) x = vgg19.pr

在Keras中微调分类模型时,它打印了
val\u acc:0.8456
。用于微调

在微调、手动加载训练模型并预测估值集后,获得的精确度要低得多的
0.28

以下代码用于估价:

model = load_model(MODEL_PATH)
...
img = kimage.load_img(img_path, target_size=target_size)
x = kimage.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = vgg19.preprocess_input(x)
pred = model.predict(x)
问题:
精度差异较大的原因可能是什么
0.85!=0.28

您正在使用不同的预处理进行培训和测试。 具体来说,

rescale = 1./255
用于训练,但是

x = vgg19.preprocess_input(x)
用于测试

imagenet\u utils.preprocess\u input()
所做的是减去平均值(根据名称在imagenet上计算):

因此,它与应用于训练数据的预处理完全不同。

使用相同的
ImageDataGenerator
我的
ImageDataGenerator
是:

train_datagen = ImageDataGenerator(
    rescale=1. / 255, ...)
能够按如下方式重现其预处理:

img = load_img(image_path, target_size=target_size)
x = img_to_array(img)
x = np.expand_dims(x, axis=0)
x *= rescale_factor

score = model.predict(x)
img = load_img(image_path, target_size=target_size)
x = img_to_array(img)
x = np.expand_dims(x, axis=0)
x *= rescale_factor

score = model.predict(x)