ehsanhaghighat / sciann

Deep learning for Engineers - Physics Informed Deep Learning
htttp://sciann.com
Other
325 stars 116 forks source link

AttributeError: module 'keras.backend' has no attribute 'get_graph' #97

Open bahrami4444 opened 1 year ago

bahrami4444 commented 1 year ago

Hi. I encounter this error when importing SciANN:

AttributeError: module 'keras.backend' has no attribute 'get_graph'

I have installed the latest version of keras and Tensorflow. Can anyone help me?

Here is the full text of the error:


AttributeError Traceback (most recent call last) Cell In[2], line 2 1 import numpy as np ----> 2 import sciann as sn 3 from sciann.utils.math import abs, diff 4 from itertools import cycle

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\sciann__init__.py:10 7 tf.get_logger().setLevel('ERROR') 8 tf.compat.v1.disable_eager_execution() ---> 10 from . import constraints 11 from . import functionals 12 from . import models

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\sciann\constraints__init.py:7 3 from future import division 4 from future__ import print_function ----> 7 from . import constraint 8 from . import data 9 from . import pde

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\sciann\constraints\constraint.py:8 5 from future import division 6 from future import print_function ----> 8 from ..utils import is_tensor 11 class Constraint(object): 12 """ Configures the condition to impose constraint. 13 14 # Arguments (...) 23 ValueError for unrecognized inputs. 24 """

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\sciann\utils__init.py:7 3 from future import division 4 from future__ import print_function ----> 7 from . import math 8 from . import utilities 9 from . import validations

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\sciann\utils\math.py:10 8 import tensorflow as tf 9 from keras import backend as K ---> 10 graph_unique_name = K.get_graph().unique_name 12 from keras.layers import Layer, Lambda, Flatten, Dense 13 from keras.layers import Dot

AttributeError: module 'keras.backend' has no attribute 'get_graph

TranTienDat-SU commented 1 year ago

I also got the same error.

nargesmalekjani commented 1 year ago

hi, I got the same error

ziqiang-shi commented 1 year ago

I also got the same error. Did you solve it?

ehsanhaghighat commented 1 year ago

It is most likely due to the latest TF changes. Can you try fresh with Python==3.9 or 3.10 and use pip install -r requirements.txt from this project: https://github.com/ehsanhaghighat/En-DeepONet

On Nov 6, 2023, at 4:29 AM, ziqiang-shi @.***> wrote:

I also got the same error. Did you solve it?

— Reply to this email directly, view it on GitHub https://github.com/sciann/sciann/issues/97#issuecomment-1794713058, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHMBIZ2XBVYXHJENNS65RTDYDDJ2JAVCNFSM6AAAAAA4IZWBI2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJUG4YTGMBVHA. You are receiving this because you are subscribed to this thread.

tirtho109 commented 1 year ago

Hi,

I had the same issue. For my project environment I used

python==3.7 numpy==1.21.6 sciann==0.7.0.1 matplotlib==3.5.3 scipy==1.7.3 pandas==1.3.5 plotly==5.18.0 tensorflow==2.11.0

And, It worked perfectly.

pdpino commented 1 year ago

I had the same issue in Google Colab that currently has TF 2.14 by default. I installed TF 2.11 and it worked.

I had to uninstall tensorflow-datasets and tensorflow-metadata that had conflicting versions with tensorflow==2.11. Overall I did:

pip uninstall tensorflow-datasets tensorflow-metadata -y
pip install tensorflow==2.11
pip install sciann