aspuru-guzik-group / chemical_vae

Code for 10.1021/acscentsci.7b00572, now running on Keras 2.0 and Tensorflow
Apache License 2.0
470 stars 178 forks source link

intro_to_chemvae.ipynb loading model AttributeError: 'str' object has no attribute 'decode' #39

Open Rdk0 opened 3 years ago

Rdk0 commented 3 years ago

executing vae = VAEUtils(directory='../models/zinc_properties') yields this error


AttributeError Traceback (most recent call last)

in () ----> 1 vae = VAEUtils(directory='../models/zinc_properties') /home/rad/miniconda3/envs/chemvae/lib/python3.6/site-packages/chemvae-1.0.0-py3.6.egg/chemvae/vae_utils.py in __init__(self, exp_file, encoder_file, decoder_file, directory) 35 self.indices_char = dict((i, c) for i, c in enumerate(chars)) 36 # encoder, decoder ---> 37 self.enc = load_encoder(self.params) 38 self.dec = load_decoder(self.params) 39 self.encode, self.decode = self.enc_dec_functions() /home/rad/miniconda3/envs/chemvae/lib/python3.6/site-packages/chemvae-1.0.0-py3.6.egg/chemvae/models.py in load_encoder(params) 77 # return encoder 78 # !# not sure if this is the right format ---> 79 return load_model(params['encoder_weights_file']) 80 81 /home/rad/miniconda3/envs/chemvae/lib/python3.6/site-packages/keras/models.py in load_model(filepath, custom_objects, compile) 230 if model_config is None: 231 raise ValueError('No model found in config file.') --> 232 model_config = json.loads(model_config.decode('utf-8')) 233 model = model_from_config(model_config, custom_objects=custom_objects) 234 AttributeError: 'str' object has no attribute 'decode'
sspleo commented 3 years ago

This issue has someething to do with h5py. Downgrade h5py to '2.10.0' or remove '.decode('utf-8')' from load_model.

Shredderroy commented 3 years ago

I experience the same issue as well.

Shredderroy commented 3 years ago

I can confirm that changing h5py to h5py=2.10.0 in environment.yml makes the error go away.