Skip to content
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

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

Open
alexberd opened this issue Mar 4, 2024 · 1 comment
Open

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

alexberd opened this issue Mar 4, 2024 · 1 comment

Comments

@alexberd
Copy link

alexberd commented Mar 4, 2024

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 tf__train_function
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 tf__r_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
Copy link
Owner

luis-armando-perez-rey commented Mar 14, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants