I am applying transfer-learning on a pre-trained network using the GPU version of keras. I don't understand how to define the parameters max_queue_size, workers, and use_multiprocessing. If I change these parameters (primarily to speed-up learning), I am unsure whether all data is still seen per epoch.
max_queue_size:
maximum size of the internal training queue which is used to "precache" samples from the generator
Question: Does this refer to how many batches are prepared on CPU? How …
我所做的:
fit_generator()。这会loss, acc, val_loss, val_acc在每个 epoch 之后产生评估指标 ( )。训练模型后,我生成评估指标 ( loss, acc) evaluate_generator()。我的期望:
fit_generator()和获得的指标evaluate_generator()是相同的。他们都应该基于整个数据集得出指标。我观察到的:
我不明白的是:
fit_generator()不同evaluate_generator()我的代码:
def generate_data(path, imagesize, nBatches):
datagen = ImageDataGenerator(rescale=1./255)
generator = datagen.flow_from_directory\
(directory=path, # path to the target directory
target_size=(imagesize,imagesize), # dimensions to which all images found will be resize
color_mode='rgb', # whether the images …Run Code Online (Sandbox Code Playgroud) python machine-learning conv-neural-network keras tensorflow
我正在使用keras在经过预训练的网络上应用转移学习。我有带有二进制类别标签的图像补丁,并且想使用CNN预测范围为[0; 1]用于看不见的图像补丁。
设置:32个批次,转换大小 层数:16
结果:经过几个时期,我的准确度已经接近1,而损失接近0,而在验证数据上,准确度保持在0.5,并且每个时期的损失都在变化。最后,CNN会针对所有看不见的补丁预测仅一个类别。
以下策略可以减少过度拟合:
我尝试了批量大小最大为512的示例,并且更改了全连接层的大小,但没有取得太大的成功。在随机测试其余部分之前,我想问一下如何调查出什么问题了,以找出上述哪种策略最具潜力。
在我的代码下面:
def generate_data(imagePathTraining, imagesize, nBatches):
datagen = ImageDataGenerator(rescale=1./255)
generator = datagen.flow_from_directory\
(directory=imagePathTraining, # path to the target directory
target_size=(imagesize,imagesize), # dimensions to which all images found will be resize
color_mode='rgb', # whether the images will be converted to have 1, 3, or 4 channels
classes=None, # optional list of class subdirectories
class_mode='categorical', # type …Run Code Online (Sandbox Code Playgroud)