lululxvi / deepxde

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

AttributeError: module 'tensorflow' has no attribute 'variance_scaling_initializer' #11

Closed malekm9 closed 4 years ago

malekm9 commented 4 years ago

Hello I was trying to run one of the examples in the DeepXDE, but I encountered this error:

AttributeError: module 'tensorflow' has no attribute 'variance_scaling_initializer'

I have pip installed the latest version of tensorflow and i am running the code in Pycharm. The thing is when I try to run it in google colab. it will successfully run.

I'll appreciate it if you let me know hat is the problem with running that in Pycharm and Anaconda.

lululxvi commented 4 years ago

Currently DeepXDE only supports TF 1.x. The latest version installed from pip should be TF 2. If you use conda, then use the following to install:

conda install tensorflow==1.15.0
Safename321 commented 4 years ago

Hi Lul Lu Im reading your paper on solved partial differential equations and this code. Im so glad I wasnt the first person with this problem. Somehow installation fails make you feel dumber than not understanding the PDEs... I also had this problem

For people with Conda, python, or package installation problems, go here https://github.com/conda/conda/issues/8149

"Try This: conda update conda (if fail) conda update --force conda (if fail) This will work for sure :100: conda update anaconda-navigator "

Then do your install.

lululxvi commented 4 years ago

@Safename321 Thank you for your information.

Safename321 commented 4 years ago

Hi Lu Lu Is there a workaround so I can keep tensorflow 2.0 ? I dont want to go back to 1.x because I have other uses for the 2.x. The above solution gave me a 12 hour installation check. Attached is a screenshot of the "conda install tensorflow==1.15.0" conflict checking. Screenshot (1700)

Despite that , it still has Error -> "AttributeError: module 'tensorflow' has no attribute 'variance_scaling_initializer'"

lululxvi commented 4 years ago

The easy way to use Tensorflow 2 is replacing the current import of Tesnforflow in all files with the following imports

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
lululxvi commented 4 years ago

DeepXDE now supports Tensorflow 2.