<p>使用ResNet50预先训练的权重,我试图建立一个分类器。代码库完全在Keras高级Tensorflow API中实现。完整的代码发布在下面的GitHub链接中。</p>
<p>源代码:<a href="https://gist.github.com/Madhivarman/676650f71ec35a5f2802631fcfa0ff73" rel="noreferrer">Classification Using RestNet50 Architecture</a></p>
<p>预训练模型的文件大小为<strong>94.7mb</strong>。</p>
<p>我加载了预先训练的文件</p>
<pre><code>new_model = Sequential()
new_model.add(ResNet50(include_top=False,
pooling='avg',
weights=resnet_weight_paths))
</code></pre>
<p>并符合模型</p>
<pre><code>train_generator = data_generator.flow_from_directory(
'path_to_the_training_set',
target_size = (IMG_SIZE,IMG_SIZE),
batch_size = 12,
class_mode = 'categorical'
)
validation_generator = data_generator.flow_from_directory(
'path_to_the_validation_set',
target_size = (IMG_SIZE,IMG_SIZE),
class_mode = 'categorical'
)
#compile the model
new_model.fit_generator(
train_generator,
steps_per_epoch = 3,
validation_data = validation_generator,
validation_steps = 1
)
</code></pre>
<p>在训练数据集中,我有两个文件夹dog和cat,每个文件夹包含将近10000个图像。当我编译脚本时,得到以下错误</p>
<blockquote>
<p>Epoch 1/1 2018-05-12 13:04:45.847298: W
tensorflow/core/framework/allocator.cc:101] Allocation of 38535168
exceeds 10% of system memory. 2018-05-12 13:04:46.845021: W
tensorflow/core/framework/allocator.cc:101] Allocation of 37171200
exceeds 10% of system memory. 2018-05-12 13:04:47.552176: W
tensorflow/core/framework/allocator.cc:101] Allocation of 37171200
exceeds 10% of system memory. 2018-05-12 13:04:48.199240: W
tensorflow/core/framework/allocator.cc:101] Allocation of 37171200
exceeds 10% of system memory. 2018-05-12 13:04:48.918930: W
tensorflow/core/framework/allocator.cc:101] Allocation of 37171200
exceeds 10% of system memory. 2018-05-12 13:04:49.274137: W
tensorflow/core/framework/allocator.cc:101] Allocation of 19267584
exceeds 10% of system memory. 2018-05-12 13:04:49.647061: W
tensorflow/core/framework/allocator.cc:101] Allocation of 19267584
exceeds 10% of system memory. 2018-05-12 13:04:50.028839: W
tensorflow/core/framework/allocator.cc:101] Allocation of 19267584
exceeds 10% of system memory. 2018-05-12 13:04:50.413735: W
tensorflow/core/framework/allocator.cc:101] Allocation of 19267584
exceeds 10% of system memory.</p>
</blockquote>
<p>有什么想法可以优化加载预先训练的模型(或)摆脱此警告消息的方式吗?</p>
<p>谢谢!</p>