lululxvi / deepxde

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

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

Open Yang1805524 opened 6 months ago

Yang1805524 commented 6 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 5 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 5 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 5 months ago

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

johnkpark commented 5 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 5 months ago

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

lululxvi commented 3 months ago

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

chengwh114 commented 2 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.