XanaduAI / quantum-transfer-learning

A transfer learning approach applied to hybrid neural networks composed of classical and quantum elements.
Apache License 2.0
71 stars 37 forks source link

'tensorflow' has no attribute 'reset_default_graph' #9

Closed mohitgour08 closed 3 years ago

mohitgour08 commented 3 years ago

Hi, @andreamari I am trying to run q2c notebook but I am getting the below error in In[4]

q2c_transfer_learning.ipynb

AttributeError: module 'tensorflow' has no attribute 'reset_default_graph' I am using versions: tenserflow==2 torch==1.3.1 torchvision==0.4.2 Pillow==6.2.1 pennylane==0.7.0

can you help me resolving this error? Thanks.

andreamari commented 3 years ago

I think the notebook was based on a previous version of TensorFlow below 2.0.0. See e.g. this link: https://stackoverflow.com/questions/62598537/module-tensorflow-has-no-atributte

I would suggest to follow the comments of the previous link or try to re-write the code in a way which is compatible with tenserflow > 2. Maybe it is just some minor syntax change in the usage of tf.placeholder, but at the moment I don't know.

josh146 commented 3 years ago

Hi @mohitgour08, did Andrea's solution solve the issue you were having?

mohitgour08 commented 3 years ago

@josh146 No, I tried using tf.compat.v1.placeholder and tf.compat.v1.reset_default_graph, but then i am getting another error i.e tf.placeholder() is not compatible with eager execution. if i disable eager execution it works but next for In[7] it is asking to enable eager execution

josh146 commented 3 years ago

@mohitgour08, from having a look at the example notebook, I believe it might be using the following versions of SF and TensorFlow:

Could you try installing these versions in a local environment and see if the notebook runs?

mohitgour08 commented 3 years ago

Thank You @josh146 I installed tensorflow==1.3 and strawberryfields==0.11.1 and it worked for me.