adityaanantharaman / transfer-learning

Support code for the medium blog on transfer learning. Link to the blog in the Readme file.
105 stars 70 forks source link

Cannot load weights #8

Open lesept777 opened 3 years ago

lesept777 commented 3 years ago

When running this, I get an error in model construction:

16736256/17225924 [============================>.] - ETA: 0s
16818176/17225924 [============================>.] - ETA: 0s
16900096/17225924 [============================>.] - ETA: 0s
16982016/17225924 [============================>.] - ETA: 0s
17063936/17225924 [============================>.] - ETA: 0s
17145856/17225924 [============================>.] - ETA: 0s
17227776/17225924 [==============================] - 30s 2us/step
Traceback (most recent call last):
  File "C:\Users\***\Documents\Python\Keras\Cats_dogs\CatsDogs.py", line 212, in <module>
    model=train_model(train_data,test_data)
  File "C:\Users\***\Documents\Python\Keras\Cats_dogs\CatsDogs.py", line 166, in train_model
    model=create_model()
  File "C:\Users\***\Documents\Python\Keras\Cats_dogs\CatsDogs.py", line 138, in create_model
    base_model=MobileNet(weights='imagenet',include_top=False, input_shape=(128, 128, 3)) #imports the mobilenet model and discards the last 1000 neuron layer.
  File "C:\Users\***\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\keras\applications\mobilenet.py", line 306, in MobileNet
    model.load_weights(weights_path)
  File "C:\Users\***\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\keras\engine\training.py", line 2211, in load_weights
    hdf5_format.load_weights_from_hdf5_group(f, self.layers)
  File "C:\Users\***\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\keras\saving\hdf5_format.py", line 660, in load_weights_from_hdf5_group
    original_keras_version = f.attrs['keras_version'].decode('utf8')
AttributeError: 'str' object has no attribute 'decode'