Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tensorflow & Keras version #4

Closed
sungkwang opened this issue Jul 1, 2020 · 7 comments
Closed

Tensorflow & Keras version #4

sungkwang opened this issue Jul 1, 2020 · 7 comments

Comments

@sungkwang
Copy link

Hello, I would like to know what version of Tensorflow and Keras should be used. For Tensorflow, I tried version 1.15 and 2.2, but I've got the following errors.
<1.15>
ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via pip install tensorflow
<2.2>
ImportError: cannot import name 'is_tensor' from 'keras.backend' (C:\Program_Files\anaconda3\envs\tf2-gpu\lib\site-packages\keras\backend.py)

I am using Windows 10 and anaconda. Tensorflow works fine. And, I installed sciann using pip as recommended here. Thank you.

@imsenthur
Copy link

Tested with Tensorflow 2.2.0 and Keras 2.4.3

The issue seems to be with 'sciann/utils/utilities.py', replace the following lines of code.

from keras.backend import is_tensor
to from tensorflow import is_tensor

from keras.initializers import random_uniform as default_bias_initializer
from keras.initializers import glorot_normal as default_kernel_initializer
from keras.initializers import Constant as default_constant_initializer
from keras.regularizers import l1_l2
to,

from keras.initializers import RandomUniform as default_bias_initializer
from keras.initializers import GlorotNormal as default_kernel_initializer
from keras.initializers import Constant as default_constant_initializer
from keras.regularizers import l1_l2

It should be up and running.

@sungkwang
Copy link
Author

I faced another problem. The error looks related to keras.

Traceback (most recent call last):
File "SciANN-BurgersEquation.py", line 62, in
u = sn.Functional('u', [t,x], 8*[20], 'tanh')
File "C:\Program_Files\anaconda3\envs\tf2-gpu\lib\site-packages\sciann\functionals\functional.py", line 145, in init
layer.name = "conct_" + layer.name.split("_")[-1]
File "C:\Program_Files\anaconda3\envs\tf2-gpu\lib\site-packages\tensorflow\python\keras\engine\base_layer.py", line 2554, in setattr
'different name.').format(name))
AttributeError: Can't set the attribute "name", likely because it conflicts with an existing read-only @Property of the object. Please choose a different name.

Using Tensorflow 2.2.0 and Keras 2.4.3.

@imsenthur
Copy link

imsenthur commented Jul 2, 2020

It should be layer._name = 'foo', since layer.name is read-only, according to https://stackoverflow.com/questions/49550182/keras-rename-model-and-layers

So I modified '\sciann\functionals\functional.py' and '\sciann\utils\math.py' which seemed to fix it. The 1D curve-fitting example: https://github.com/sciann/sciann/blob/master/examples/example-fitting-1d.py worked as expected, but others did not. There are few problems during eager execution tensorflow/tensorflow#34944.

Maybe it doesn't support Tensorflow 2.2.0. I'll try it out with >=1.14.

@imsenthur
Copy link

imsenthur commented Jul 3, 2020

Works on Tensorflow 1.14.0. Downgrade your Keras version to 2.3.0 with pip install --upgrade keras==2.3.0. You can also try out Tensorflow 1.15.0 with Keras 2.3.1. Kindly refer to https://docs.floydhub.com/guides/environments/.

@dimitri-voytan
Copy link

I was able to get around this issue using Tensorflow 1.15.2. I am using Google Colab notebooks. Tensorflow v2.3 is imported by default and I get the same problem as @sungkwang . These imports appear to work, but I can't verify that they aren't broken in a subtle way.

%tensorflow_version 1.x import tensorflow as tf !pip install sciann

@sciann
Copy link
Collaborator

sciann commented Sep 1, 2020

please use TF <= 2.2.0 and Keras==2.3.1. A new release is coming soon that support the latest release of tensorflow.

@sciann
Copy link
Collaborator

sciann commented Sep 2, 2020

Should be resolved now - get the latest v0.5.0.0 version.

@sciann sciann closed this as completed Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants