1
$\begingroup$

In several Kaggle kernels I've seen that people often import their weights into Keras' DenseNet. In the following case, I believe the weights are sourced from this github repo and contain the pre-trained weights on the ImageNet dataset.

densenet = DenseNet121(
    weights='../input/densenet-keras/DenseNet-BC-121-32-no-top.h5',
    include_top=False,
    input_shape=(im_size,im_size,3)
)

Why do people load weights from a file when you can use the ImageNet weights within Keras by specifying weights='imagenet' in the following manner?

keras.applications.densenet.DenseNet121(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000)

Is there a difference that I should be aware of or is it simply a matter of personal preference?

$\endgroup$
1
$\begingroup$

Because it must have been a kernel only competition, with: 'the following conditions must be met:"Internet must be turned off".'

When we use " weights='imagenet' " , the notebook will connect to internet to download the weights. Since the user cannot connect to internet for that particular competition it is better to upload the weights as data source, and then import it for use.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.