luis-armando-perez-rey / diffusion_vae

Apache License 2.0
24 stars 5 forks source link

module 'tensorflow' has no attribute 'log' #1

Open alexberd opened 8 months ago

alexberd commented 8 months ago

I am using: python '3.8.16' tensorflow '2.10.1' imageio '2.34.0' scipy '1.10.1'

Below is the eror, I am receiving: Epoch 1/100 Reconstruction loss is binary cross entropy Traceback (most recent call last): File "diffusion_vae.py", line 142, in main(sys.argv[1:]) File "diffusion_vae.py", line 132, in main exp.run_vae() File "C:\Users\alexberd\Desktop\github\Variational Autoencoders\diffusion_vae\modules\experiment_control\experiment_class.py", line 595, in run_vae self.diffusionVAE.vae.fit(self.train_data, self.target_data, File "C:\Users\alexberd.conda\envs\tensorflow\lib\site-packages\keras\utils\traceback_utils.py", line 70, in error_handler raise e.with_traceback(filtered_tb) from None File "C:\Users\alexberd\AppData\Local\Temp__autograph_generated_fileq9gx1evd.py", line 15, in tftrainfunction retval = ag.converted_call(ag.ld(step_function), (ag.ld(self), ag.ld(iterator)), None, fscope) File "C:\Users\alexberd\AppData\Local\Temp__autograph_generated_filev8iyt31v.py", line 12, in tf__vae_loss loss = ag.converted_call(ag.ld(K).mean, ((ag.converted_call(ag.ld(r_loss), (ag.ld(inputs), ag.ld(outputs)), None, fscope) + ag__.converted_call(ag.ld(kl_loss), (ag.ld(inputs), ag.ld(outputs)), None, fscope)),), None, fscope) File "C:\Users\alexberd\AppData\Local\Temp__autograph_generated_filedorldv1q.py", line 82, in tfr_loss ag__.if_stmt((ag.ld(self).r_loss == 'mse'), if_body_1, else_body_1, get_state_3, set_state_3, ('loss',), 1) File "C:\Users\alexberd\AppData\Local\Temp__autograph_generated_filedorldv1q.py", line 77, in else_body_1 ag.if_stmt((ag__.ld(self).r_loss == 'binary'), if_body, else_body, get_state_2, set_state_2, ('loss',), 1) File "C:\Users\alexberd\AppData\Local\Temp__autograph_generated_filedorldv1q.py", line 54, in if_body loss = (((- ag.ld(inputs)) ag__.converted_call(ag.ld(tf).log, ((ag.ld(epsilon) + ag.ld(outputs)),), None, fscope)) - ((1 - ag.ld(inputs)) ag__.converted_call(ag.ld(tf).log, (((ag.ld(epsilon) + 1) - ag__.ld(outputs)),), None, fscope))) AttributeError: in user code:

File "C:\Users\alexberd\.conda\envs\tensorflow\lib\site-packages\keras\engine\training.py", line 1160, in train_function  *
    return step_function(self, iterator)
File "C:\Users\alexberd\Desktop\github\Variational Autoencoders\diffusion_vae\modules\deltavae\deltavae_latent_spaces\deltavae_parent.py", line 246, in vae_loss  *
    loss = K.mean(r_loss(inputs, outputs) + kl_loss(inputs, outputs))
File "C:\Users\alexberd\Desktop\github\Variational Autoencoders\diffusion_vae\modules\deltavae\deltavae_latent_spaces\deltavae_parent.py", line 221, in r_loss  *
    loss = -inputs * tf.log(epsilon + outputs)                        - (1 - inputs) * tf.log(epsilon + 1 - outputs)

AttributeError: module 'tensorflow' has no attribute 'log'
luis-armando-perez-rey commented 8 months ago

I see, thank you for pointing this out. Probably the appropriate call for the logarithm now is tf.math.log https://www.tensorflow.org/api_docs/python/tf/math/log. If you would like to test it and if it works make a pull request and I would gladly merge it. Otherwise I will implement this a bit later.