I’m trying out transfer learning and I have downloaded weights for VGG19 model from ImageNet dataset. It downloaded as a “.mat” file. At first I tried to load in the entire .mat file as
import tensorflow as tf from tensorflow.keras.applications.vgg19 import VGG19 model_path = os.path.join('trained_model', 'imagenet-vgg-verydeep-19.mat') pre_trained_model = VGG19(weights = None, include_top = False) pre_trained_model.load_weights(model_path)
but, I got the following error.
OSError: Unable to open file (file signature not found)
Then I tried the
set_weights() method instead of
load_weights() , as
pre_trained_model = VGG19(weights = None, include_top = False) pre_trained_model.set_weights(model_path)
then I got the following error,
ValueError: You called `set_weights(weights)` on layer "vgg19" with a weight list of length 42, but the layer was expecting 32 weights. Provided weights: trained_model\imagenet-vgg-verydeep-19.mat...
I have also tried
pre_trained_model = VGG19(weights = None, include_top = True) pre_trained_model.set_weights(model_path)
but, I still get the same errors.
I have downloaded the weights from https://www.kaggle.com/teksab/imagenetvggverydeep19mat