The `weights` argument should be either random initialization or pre-training on ImageNet

First look at my source code:

from keras.applications.vgg16 import VGG16
vgg16_weights = '../Dataset/Weight_for_Cats_VS_Dogs/vgg16_weights_tf_dim_ordering_tf_kernels.h5'
vgg16_model = VGG16(weights=vgg16_weights)

 

The reason given:

But I found that reported the wrong solution to the problem but could not find on the Internet. Chance to see keras source code , as well as tips being given to understand, the reason being given is that I download from the Internet is not a weight for imagenet, so this problem.

 

 

solution:

Solution a: loading model directly arranged above None does not load corresponding to weight

vgg16_model = VGG16(weights=None)

 

Solution two: directly to the set model can be loaded above imagenet is keras imagenet related to the weight placed on the server, if set to imagenet then read directly downloaded to the local on the server.

vgg16_model = VGG16(weights='imagenet')

 

Guess you like

Origin blog.csdn.net/qq_41776781/article/details/94550179