UNetPlusPlus icon indicating copy to clipboard operation
UNetPlusPlus copied to clipboard

Implementing in colab

Open Swathi-Guptha opened this issue 4 years ago • 3 comments

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?

Swathi-Guptha avatar Aug 24 '20 05:08 Swathi-Guptha

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

maksym33 avatar Aug 24 '20 08:08 maksym33

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

Swathi-Guptha avatar Aug 25 '20 04:08 Swathi-Guptha

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

ItsCRC avatar Jan 17 '21 08:01 ItsCRC