【发布时间】:2018-04-06 09:01:00
【问题描述】:
我正在尝试微调 Inception-v3,但无论我选择冻结哪一层,我都会得到随机预测。我发现其他人也有同样的问题:https://github.com/keras-team/keras/issues/9214。似乎问题出在将 BN 层设置为不可训练。 现在我正在尝试获取我想要冻结的最后一层的输出并将其用作以下层的输入,然后我将对其进行训练:
train_generator = train_datagen.flow_from_directory(
os.path.join(directory, "train_data"),
target_size=size,
interpolation="bilinear",
classes=["a", "b", "c","d"],
batch_size=1,
shuffle=False) base_model = InceptionV3(weights='imagenet', include_top=True, input_shape=(299, 299, 3))
model_features = Model(inputs=base_model.input, outputs=base_model.get_layer(
self.Inception_Fine_Tune_Layers[layer_freeze]).output)
#I want to use this as input
values_train = model_features.predict_generator(train_generator, verbose=1)
但是,虽然我有 12Gb,但我得到了这样的内存错误,这超出了我的需要:
....
I tensorflow/core/common_runtime/bfc_allocator.cc:696] 1 Chunks of size 3268864 totalling 3.12MiB
I tensorflow/core/common_runtime/bfc_allocator.cc:696] 1 Chunks of size 3489024 totalling 3.33MiB
I tensorflow/core/common_runtime/bfc_allocator.cc:696] 1 Chunks of size 4211968 totalling 4.02MiB
I tensorflow/core/common_runtime/bfc_allocator.cc:696] 1 Chunks of size 5129472 totalling 4.89MiB
I tensorflow/core/common_runtime/bfc_allocator.cc:700] Sum Total of in-use chunks: 3.62GiB
I tensorflow/core/common_runtime/bfc_allocator.cc:702] Stats:
Limit: 68719476736
InUse: 3886957312
MaxInUse: 3889054464
NumAllocs: 3709
MaxAllocSize: 8388608
任何关于如何解决该问题或其他解决方法以微调 Inception 的建议都会非常有帮助。
【问题讨论】:
标签: performance tensorflow keras