- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的任务是根据缺陷对种子进行分类。我有 7 个类的大约 14k 图像(它们的大小不相等,有些类有更多照片,有些类有更少)。我尝试从头开始训练 Inception V3,准确率约为 90%。然后我尝试使用带有 ImageNet 权重的预训练模型进行迁移学习。我从没有顶级 fc 层的 applications
导入了 inception_v3
,然后在文档中添加了我自己的内容。我以以下代码结束:
# Setting dimensions
img_width = 454
img_height = 227
###########################
# PART 1 - Creating Model #
###########################
# Creating InceptionV3 model without Fully-Connected layers
base_model = InceptionV3(weights='imagenet', include_top=False, input_shape = (img_height, img_width, 3))
# Adding layers which will be fine-tunned
x = base_model.output
x = GlobalAveragePooling2D()(x)
x = Dense(1024, activation='relu')(x)
predictions = Dense(7, activation='softmax')(x)
# Creating final model
model = Model(inputs=base_model.input, outputs=predictions)
# Plotting model
plot_model(model, to_file='inceptionV3.png')
# Freezing Convolutional layers
for layer in base_model.layers:
layer.trainable = False
# Summarizing layers
print(model.summary())
# Compiling the CNN
model.compile(optimizer = 'adam', loss = 'categorical_crossentropy', metrics = ['accuracy'])
##############################################
# PART 2 - Images Preproccessing and Fitting #
##############################################
# Fitting the CNN to the images
train_datagen = ImageDataGenerator(rescale = 1./255,
rotation_range=30,
width_shift_range=0.2,
height_shift_range=0.2,
shear_range = 0.2,
zoom_range = 0.2,
horizontal_flip = True,
preprocessing_function=preprocess_input,)
valid_datagen = ImageDataGenerator(rescale = 1./255,
preprocessing_function=preprocess_input,)
train_generator = train_datagen.flow_from_directory("dataset/training_set",
target_size=(img_height, img_width),
batch_size = 4,
class_mode = "categorical",
shuffle = True,
seed = 42)
valid_generator = valid_datagen.flow_from_directory("dataset/validation_set",
target_size=(img_height, img_width),
batch_size = 4,
class_mode = "categorical",
shuffle = True,
seed = 42)
STEP_SIZE_TRAIN = train_generator.n//train_generator.batch_size
STEP_SIZE_VALID = valid_generator.n//valid_generator.batch_size
# Save the model according to the conditions
checkpoint = ModelCheckpoint("inception_v3_1.h5", monitor='val_acc', verbose=1, save_best_only=True, save_weights_only=False, mode='auto', period=1)
early = EarlyStopping(monitor='val_acc', min_delta=0, patience=10, verbose=1, mode='auto')
#Training the model
history = model.fit_generator(generator=train_generator,
steps_per_epoch=STEP_SIZE_TRAIN,
validation_data=valid_generator,
validation_steps=STEP_SIZE_VALID,
epochs=25,
callbacks = [checkpoint, early])
但我得到了糟糕的结果:45% 的准确率。我想应该会更好。我有一些假设可能会出现问题:
preprocessing_function=preprocess_input
(在网上发现一篇文章,它非常重要,所以我决定添加它)。rotation_range=30
、width_shift_range=0.2
、height_shift_range=0.2
和 horizontal_flip = True
学习更多地扩充数据。或者我在其他方面失败了?
编辑:我发布了训练历史图。也许它包含有值(value)的信息:
编辑2:随着InceptionV3参数的变化:
VGG16 进行比较:
最佳答案
@今天,我发现了一个问题。这是因为批量归一化层及其卡住时的行为发生了一些变化。 Chollet先生给出了一个解决方法,但我使用了datumbox制作的Keras fork,这解决了我的问题。主要问题描述如下:
https://github.com/keras-team/keras/pull/9965
现在我的准确率约为 85%,并正在努力提高它。
关于python - 迁移学习准确性差,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51994344/
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 9 年前。 Improve
介绍篇 什么是MiniApis? MiniApis的特点和优势 MiniApis的应用场景 环境搭建 系统要求 安装MiniApis 配置开发环境 基础概念 MiniApis架构概述
我正在从“JavaScript 圣经”一书中学习 javascript,但我遇到了一些困难。我试图理解这段代码: function checkIt(evt) { evt = (evt) ? e
package com.fastone.www.javademo.stringintern; /** * * String.intern()是一个Native方法, * 它的作用是:如果字
您会推荐哪些资源来学习 AppleScript。我使用具有 Objective-C 背景的传统 C/C++。 我也在寻找有关如何更好地开发和从脚本编辑器获取更快文档的技巧。示例提示是“查找要编写脚本的
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 4年前关闭。 Improve thi
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 7年前关闭。 Improve thi
关闭。这个问题不符合 Stack Overflow guidelines 。它目前不接受答案。 想改善这个问题吗?更新问题,以便堆栈溢出为 on-topic。 6年前关闭。 Improve this
我是塞内加尔的阿里。我今年60岁(也许这是我真正的问题-笑脸!!!)。 我正在学习Flutter和Dart。今天,我想使用给定数据模型的列表(它的名称是Mortalite,请参见下面的代码)。 我尝试
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题? Update the question所以它是on-topic对于堆栈溢出。 9年前关闭。 Improve this que
学习 Cappuccino 的最佳来源是什么?我从事“传统”网络开发,但我对这个新框架非常感兴趣。请注意,我对 Objective-C 毫无了解。 最佳答案 如上所述,该网站是一个好地方,但还有一些其
我正在学习如何使用 hashMap,有人可以检查我编写的这段代码并告诉我它是否正确吗?这个想法是有一个在公司工作的员工列表,我想从 hashMap 添加和删除员工。 public class Staf
我正在尝试将 jQuery 与 CoffeScript 一起使用。我按照博客中的说明操作,指示使用 $ -> 或 jQuery -> 而不是 .ready() 。我玩了一下代码,但我似乎无法理解我出错
还在学习,还有很多问题,所以这里有一些。我正在进行 javascript -> PHP 转换,并希望确保这些做法是正确的。是$dailyparams->$calories = $calories;一条
我目前正在学习 SQL,以便从我们的 Magento 数据库制作一个简单的 RFM 报告,我目前可以通过导出两个查询并将它们粘贴到 Excel 模板中来完成此操作,我想摆脱 Excel 模板。 我认为
我知道我很可能会因为这个问题而受到抨击,但没有人问,我求助于你。这是否是一个正确的 javascript > php 转换 - 在我开始不良做法之前,我想知道这是否是解决此问题的正确方法。 JavaS
除了 Ruby-Doc 之外,哪些来源最适合获取一些示例和教程,尤其是关于 Ruby 中的 Tk/Tile?我发现自己更正常了 http://www.tutorialspoint.com/ruby/r
我只在第一次收到警告。这正常吗? >>> cv=LassoCV(cv=10).fit(x,y) C:\Python27\lib\site-packages\scikit_learn-0.14.1-py
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be
我是一名优秀的程序员,十分优秀!