【发布时间】:2019-05-24 03:17:17
【问题描述】:
我有一个包含 600 张图像的训练数据集,分辨率为 (512*512*1),分为 2 类(每类 300 张图像)。使用一些增强技术,我将数据集增加到 10000 张图像。经过以下预处理步骤
all_images=np.array(all_images)/255.0
all_images=all_images.astype('float16')
all_images=all_images.reshape(-1,512,512,1)
saved these images to H5 file.
我使用 AlexNet 架构进行分类,其中包含 3 个卷积、3 个重叠的最大池层。 我想知道以下哪种情况最适合使用内存大小限制为 12GB 的 Google Colab 进行训练。
1. model.fit(x,y,validation_split=0.2)
# For this I have to load all data into memory and then applying an AlexNet to data will simply cause Resource-Exhaust error.
2. model.train_on_batch(x,y)
# For this I have written a script which randomly loads the data batch-wise from H5 file into the memory and train on that data. I am confused by the property of train_on_batch() i.e single gradient update. Do this will affect my training procedure or will it be same as model.fit().
3. model.fit_generator()
# giving the original directory of images to its data_generator function which automatically augments the data and then train using model.fit_generator(). I haven't tried this yet.
请指导我在这些方法中哪种方法对我来说是最好的。我已经阅读了很多关于 model.fit()、model.train_on_batch() 和 model.fit_generator() 的答案 Here、Here 和 Here,但我仍然感到困惑。
【问题讨论】:
标签: python-3.x tensorflow keras deep-learning computer-vision