aspuru-guzik-group / chemical_vae

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

AttributeError: can't set attribute #4

Open jerryhluo opened 6 years ago

jerryhluo commented 6 years ago

I am using Anaconda Python 3.6 with latest Keras and other libraries. When I run python -m chemvae.train_vae It complains: Traceback (most recent call last): File "Anaconda3\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "Anaconda3\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "chemical_vae\chemvae\train_vae.py", line 399, in main_no_prop(params) File "chemical_vae\chemvae\train_vae.py", line 229, in main_no_prop AE_only_model, encoder, decoder, kl_loss_var = load_models(params) File "chemical_vae\chemvae\train_vae.py", line 161, in load_models decoder = decoder_model(params) File "chemical_vae\chemvae\models.py", line 137, in decoder_model implementation=params['terminal_GRU_implementation'])([x_dec, true_seq_in]) File "chemical_vae\chemvae\tgru_k2_gpu.py", line 86, in init self.units = units AttributeError: can't set attribute

I tried https://github.com/keras-team/keras/issues/7736 And changed the related lines to: try: self.units = units except AttributeError: self._units = units try: self.recurrent_dropout = min(1., max(0., recurrent_dropout)) except AttributeError: self._recurrent_dropout = min(1., max(0., recurrent_dropout))

Then it complains: ValueError: Layer decoder_tgru expects 3 inputs, but it received 2 input tensors. Input received: [<tf.Tensor 'decoder_gru2_2/transpose_1:0' shape=(?, ?, 488) dtype=float32>, <tf.Tensor 'decoder_true_seq_input_2:0' shape=(?, 120, 35) dtype=float32>]

Please help...

jnwei-zz commented 6 years ago

Hi, This library is only supported on Keras versions between 1.0 and 2.0.7. Perhaps you are running a newer version of Keras?

On Tue, Apr 10, 2018 at 2:43 PM leanhug notifications@github.com wrote:

I am using Anaconda Python 3.6 with latest Keras and other libraries. When I run python -m chemvae.train_vae It complains: Traceback (most recent call last): File "Anaconda3\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "Anaconda3\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "chemical_vae\chemvae\train_vae.py", line 399, in main_no_prop(params) File "chemical_vae\chemvae\train_vae.py", line 229, in main_no_prop AE_only_model, encoder, decoder, kl_loss_var = load_models(params) File "chemical_vae\chemvae\train_vae.py", line 161, in load_models decoder = decoder_model(params) File "chemical_vae\chemvae\models.py", line 137, in decoder_model implementation=params['terminal_GRU_implementation'])([x_dec, true_seq_in]) File "chemical_vae\chemvae\tgru_k2_gpu.py", line 86, in init self.units = units AttributeError: can't set attribute

I tried keras-team/keras#7736 https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_keras-2Dteam_keras_issues_7736&d=DwMCaQ&c=WO-RGvefibhHBZq3fL85hQ&r=UPzYrSHLXjnX3tYn90C8Ljjzb-yfrb1UtMOxOFh-tKk&m=BPHec2W6KKtCLQUQEIk-JpSfFxczLFKZOiIKwhkrxoU&s=Ai-Vk2JvGPjiqpRPNiwXw-UsbuL15ATwXFFJwN76vOM&e= And changed the related lines to: try: self.units = units except AttributeError: self._units = units try: self.recurrent_dropout = min(1., max(0., recurrent_dropout)) except AttributeError: self._recurrent_dropout = min(1., max(0., recurrent_dropout))

Then it complains: ValueError: Layer decoder_tgru expects 3 inputs, but it received 2 input tensors. Input received: [<tf.Tensor 'decoder_gru2_2/transpose_1:0' shape=(?, ?, 488) dtype=float32>, <tf.Tensor 'decoder_true_seq_input_2:0' shape=(?, 120, 35) dtype=float32>]

Please help...

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_aspuru-2Dguzik-2Dgroup_chemical-5Fvae_issues_4&d=DwMCaQ&c=WO-RGvefibhHBZq3fL85hQ&r=UPzYrSHLXjnX3tYn90C8Ljjzb-yfrb1UtMOxOFh-tKk&m=BPHec2W6KKtCLQUQEIk-JpSfFxczLFKZOiIKwhkrxoU&s=_TxPnq7yQ5Jd4DI1BF8YfQ6fg6YmrXoqbnIydTN3lVY&e=, or mute the thread https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AOe70D5Q7Isu-2Ds15iH3YIWJCfzXNNXr4ks5tnP1pgaJpZM4TOy-5FK&d=DwMCaQ&c=WO-RGvefibhHBZq3fL85hQ&r=UPzYrSHLXjnX3tYn90C8Ljjzb-yfrb1UtMOxOFh-tKk&m=BPHec2W6KKtCLQUQEIk-JpSfFxczLFKZOiIKwhkrxoU&s=a6ckcfkQGlqM0IBU31LGN8NL1cag7tEyha0wtw2jDns&e= .

jerryhluo commented 6 years ago

Thank you!

I created a virtual environment and installed Keras 2.0.7 and made it work.

There is one minor thing to fix. Keras will still complain File "Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py", line 323, in variable v.constraint = constraint AttributeError: can't set attribute

To fix it, replace v.constraint = constraint with: try: v.constraint = constraint except AttributeError: v._constraint = constraint

jnwei-zz commented 6 years ago

Great, thanks for sharing the fix!

On Tue, Apr 10, 2018 at 3:44 PM leonhug notifications@github.com wrote:

Thank you!

I created a virtual environment and installed Keras 2.0.7 and made it work.

There is one minor thing to fix. Keras will still complain File "Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py", line 323, in variable v.constraint = constraint

AttributeError: can't set attribute

To fix it, replace v.constraint = constraint with: try: v.constraint = constraint except AttributeError: v._constraint = constraint

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_aspuru-2Dguzik-2Dgroup_chemical-5Fvae_issues_4-23issuecomment-2D380223791&d=DwMFaQ&c=WO-RGvefibhHBZq3fL85hQ&r=UPzYrSHLXjnX3tYn90C8Ljjzb-yfrb1UtMOxOFh-tKk&m=B6-uiEAHCq5kySe6vF9eBnEkIIGjKidoxkLpdlXg2sI&s=Bc1zi1jXhGwZD5gQNQ4KHk2ZgR6Io7ku2AXnFBNzm5M&e=, or mute the thread https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AOe70GNsSs4MWkq7tJazbU-5FeNgHE6DlUks5tnQuugaJpZM4TOy-5FK&d=DwMFaQ&c=WO-RGvefibhHBZq3fL85hQ&r=UPzYrSHLXjnX3tYn90C8Ljjzb-yfrb1UtMOxOFh-tKk&m=B6-uiEAHCq5kySe6vF9eBnEkIIGjKidoxkLpdlXg2sI&s=mL2XD_XN0PJSLMcIMuLJJLKu3Jbt3bV-nAqSEy_hoGk&e= .