lululxvi / deepxde

A library for scientific machine learning and physics-informed learning
https://deepxde.readthedocs.io
GNU Lesser General Public License v2.1
2.76k stars 758 forks source link

AttributeError: `dense` is not available with Keras 3. #1682

Open Yang1805524 opened 8 months ago

Yang1805524 commented 8 months ago

AttributeError: dense is not available with Keras 3. I'm getting an error when running an example file in PyCharm. How can I resolve it?

jdellag commented 7 months ago

I was running into this issue when I created a new Python 3.12 virtual environment. When I downgraded back to 3.11 and installed the necessary packages and dependencies it solved itself.

liaochunyang commented 7 months ago

I had the same issue. It was solved when I use tensorflow as the supported backend, not tensorflow.compat.v1. Some necessary packages should be installed.

donaldcummins commented 7 months ago

What is the recommended TensorFlow environment to run DeepXDE? TensorFlow 2.7.0 is very old now...

johnkpark commented 7 months ago

I was able to fix the issue by downgrading tensorflow to 2.15.0 and tensorflow-probability to 0.23.0 . i.e.

pip3 install tensorflow==2.15.0 tensorflow-probability==0.23.0
jdellag commented 7 months ago

I have a working requirements.txt as of 4.16.2024 for anyone using apple silicon; please send a message.

lululxvi commented 4 months ago

See https://deepxde.readthedocs.io/en/latest/user/installation.html#installation

chengwh114 commented 4 months ago

I was able to fix the issue by downgrading tensorflow to 2.15.0 and tensorflow-probability to 0.23.0 . i.e.

pip3 install tensorflow==2.15.0 tensorflow-probability==0.23.0

Mr. Johnkpark's solution works. But these dependencies need to be installed before deepxde, in case someone doesn't know.