-
Notifications
You must be signed in to change notification settings - Fork 740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ValueError: Unable to load weights 03_04_vae_digits_analysis.ipynb #85
Comments
Hi, ValueError Traceback (most recent call last) ~\Deep_Learning\H_Generative_Deep_Learning\utils\loaders.py in load_model(model_class, run_folder) ~\Deep_Learning\H_Generative_Deep_Learning\models\VAE.py in load_weights(self, filepath) ~\anaconda3\lib\site-packages\tensorflow\python\keras\engine\training.py in load_weights(self, filepath, by_name, skip_mismatch, options) ValueError: Unable to load weights saved in HDF5 format into a subclassed Model which has not created its variables yet. Call the Model first, then load the weights. Any ideas for a fix? Best regards, |
I encountered the same problem, and I solved it by setting class VAEModel(Model):
def __init__(self, encoder, decoder, r_loss_factor, **kwargs):
super(VAEModel, self).__init__(**kwargs)
self.encoder = encoder
self.decoder = decoder
self.r_loss_factor = r_loss_factor
self.built = True # added |
From Japan.
I'm not good at English, so it may be hard to read. Sorry.
When I used load_model() in 03_04_vae_digits_analysis.ipynb, I got an error message.
ValueError Traceback (most recent call last)
in
----> 1 vae = load_model(VariationalAutoencoder, RUN_FOLDER)
~\Desktop\study\GDL_code\utils\loaders.py in load_model(model_class, folder)
138 model = model_class(*params)
139
--> 140 model.load_weights(os.path.join(folder, 'weights/weights.h5'))
141
142 return model
~\Desktop\study\GDL_code\models\VAE.py in load_weights(self, filepath)
204
205 def load_weights(self, filepath):
--> 206 self.model.load_weights(filepath)
207
208 def train(self
~\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\keras\engine\training.py in load_weights(self, filepath, by_name, skip_mismatch, options)
2221 if not self._is_graph_network and not self.built:
2222 raise ValueError(
-> 2223 'Unable to load weights saved in HDF5 format into a subclassed '
2224 'Model which has not created its variables yet. Call the Model '
2225 'first, then load the weights.')
ValueError: Unable to load weights saved in HDF5 format into a subclassed Model which has not created its variables yet. Call the Model first, then load the weights.
Please give me any advice.
Thank you.
The text was updated successfully, but these errors were encountered: