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

Implementing in colab #52

Open
Swathi-Guptha opened this issue Aug 24, 2020 · 3 comments
Open

Implementing in colab #52

Swathi-Guptha opened this issue Aug 24, 2020 · 3 comments

Comments

@Swathi-Guptha
Copy link

Swathi-Guptha commented Aug 24, 2020

I have been trying to implement this code in colab but there is alot of version issue.
The requirements file have tensorflow=1.14.1 which is supported by cuda=10.0
My colab have tensorflow=2.2.0 which is supported by 10.1 and i'm getting the following error:
AttributeError Traceback (most recent call last)

in ()
----> 1 model = Xnet(backbone_name='resnet50', encoder_weights='imagenet', decoder_block_type='transpose') # build UNet++

7 frames

/usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py in placeholder(shape, ndim, dtype, sparse, name)
513 x = tf.sparse_placeholder(dtype, shape=shape, name=name)
514 else:
--> 515 x = tf.placeholder(dtype, shape=shape, name=name)
516 x._keras_shape = shape
517 x._uses_learning_phase = False

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

Can there be any way in which the above version problem can be rectified?

@maksym33
Copy link

Maybe try:
%tensorflow_version 1.x
from https://colab.research.google.com/notebooks/tensorflow_version.ipynb ?

@Swathi-Guptha
Copy link
Author

1.! python -m pip install Keras==2.3.1 tensorflow==2.1.0
2. import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
print(tf.version)

After executing the requirements file we need to run the above two steps to run the code in colab

@ItsCRC
Copy link

ItsCRC commented Jan 17, 2021

After following your instructions from the above comment on colab, it gives this error after first epoch:
Epoch 1/70
74/74 [==============================] - 273s 4s/step - loss: 0.4780 - dice_coef: 0.5583 - val_loss: 5.9511 - val_dice_coef: 0.2558
NotImplementedError Traceback (most recent call last)
in ()
----> 1 history = model.fit(train_generator, validation_data=valid_generator, callbacks=callbackslist, epochs=70, verbose=1)
/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/ops/resource_variable_ops.py in numpy(self)
582 return self.read_value().numpy()
583 raise NotImplementedError(
--> 584 "numpy() is only available when eager execution is enabled.")
585
586 @deprecated(None, "Prefer Dataset.range instead.")

NotImplementedError: numpy() is only available when eager execution is enabled.

I tried:
import tensorflow.compat.v1 as tf
tf.enable_eager_execution()

tf.disable_v2_behavior()
print(tf.version)

Still same error....@Swathi-Gupta

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