Mask_RCNN
Mask_RCNN copied to clipboard
AttributeError: module 'tensorflow' has no attribute 'placeholder'
Suddenly have this problem. Isit tensorflow problem? How can I solve this? I install tensorflow 1.14 temporarily to run the code, but it is very slow while training. Please Help
/content/drive/My Drive/FYP2
2020-03-30 07:50:00.328488: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
Using TensorFlow backend.
Weights: coco
Dataset: dataset
Logs: /content/drive/My Drive/FYP2/logs
Configurations:
BACKBONE resnet101
BACKBONE_STRIDES [4, 8, 16, 32, 64]
BATCH_SIZE 2
BBOX_STD_DEV [0.1 0.1 0.2 0.2]
COMPUTE_BACKBONE_SHAPE None
DETECTION_MAX_INSTANCES 3
DETECTION_MIN_CONFIDENCE 0.5
DETECTION_NMS_THRESHOLD 0.9
FPN_CLASSIF_FC_LAYERS_SIZE 1024
GPU_COUNT 1
GRADIENT_CLIP_NORM 5.0
IMAGES_PER_GPU 2
IMAGE_CHANNEL_COUNT 3
IMAGE_MAX_DIM 512
IMAGE_META_SIZE 15
IMAGE_MIN_DIM 512
IMAGE_MIN_SCALE 0
IMAGE_RESIZE_MODE square
IMAGE_SHAPE [512 512 3]
LEARNING_MOMENTUM 0.9
LEARNING_RATE 0.005
LOSS_WEIGHTS {'rpn_class_loss': 1.0, 'rpn_bbox_loss': 1.0, 'mrcnn_class_loss': 1.0, 'mrcnn_bbox_loss': 1.0, 'mrcnn_mask_loss': 1.0}
MASK_POOL_SIZE 14
MASK_SHAPE [28, 28]
MAX_GT_INSTANCES 6
MEAN_PIXEL [53.129, 53.129, 53.129]
MINI_MASK_SHAPE (56, 56)
NAME lesion
NUM_CLASSES 3
POOL_SIZE 7
POST_NMS_ROIS_INFERENCE 1000
POST_NMS_ROIS_TRAINING 2500
PRE_NMS_LIMIT 6000
ROI_POSITIVE_RATIO 0.33
RPN_ANCHOR_RATIOS [0.5, 1, 2]
RPN_ANCHOR_SCALES (32, 64, 128, 256, 512)
RPN_ANCHOR_STRIDE 1
RPN_BBOX_STD_DEV [0.1 0.1 0.2 0.2]
RPN_NMS_THRESHOLD 0.7
RPN_TRAIN_ANCHORS_PER_IMAGE 256
STEPS_PER_EPOCH 400
TOP_DOWN_PYRAMID_SIZE 256
TRAIN_BN False
TRAIN_ROIS_PER_IMAGE 400
USE_MINI_MASK True
USE_RPN_ROIS True
VALIDATION_STEPS 50
WEIGHT_DECAY 0.0001
Traceback (most recent call last):
File "lesion.py", line 447, in <module>
model_dir=args.logs)
File "/content/drive/My Drive/FYP2/mrcnn/model.py", line 1837, in __init__
self.keras_model = self.build(mode=mode, config=config)
File "/content/drive/My Drive/FYP2/mrcnn/model.py", line 1856, in build
shape=[None, None, config.IMAGE_SHAPE[2]], name="input_image")
File "/usr/local/lib/python3.6/dist-packages/keras/engine/input_layer.py", line 178, in Input
input_tensor=tensor)
File "/usr/local/lib/python3.6/dist-packages/keras/legacy/interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/keras/engine/input_layer.py", line 87, in __init__
name=self.name)
File "/usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py", line 541, in placeholder
x = tf.placeholder(dtype, shape=shape, name=name)
AttributeError: module 'tensorflow' has no attribute 'placeholder'
Same issue since today.. Worked 3 days ago suddenly cannot run it anymore:
AttributeError Traceback (most recent call last)
5 frames /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py in placeholder(shape, ndim, dtype, sparse, name) 539 x = tf.sparse_placeholder(dtype, shape=shape, name=name) 540 else: --> 541 x = tf.placeholder(dtype, shape=shape, name=name) 542 x._keras_shape = shape 543 x._uses_learning_phase = False
AttributeError: module 'tensorflow' has no attribute 'placeholder'
Facing the same error: This seems to occur because of the changes in Tensorflow 2.0 which no more has placeholders and works more in a pythonic way.
This page can be used as a guide to do the needful for the issues we are facing!
https://www.tensorflow.org/guide/migrate
AttributeError Traceback (most recent call last)
5 frames /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py in placeholder(shape, ndim, dtype, sparse, name) 539 x = tf.sparse_placeholder(dtype, shape=shape, name=name) 540 else: --> 541 x = tf.placeholder(dtype, shape=shape, name=name) 542 x._keras_shape = shape 543 x._uses_learning_phase = False
AttributeError: module 'tensorflow' has no attribute 'placeholder'
Downgrade the tensorflow version as 1 using the following command %tensorflow_version 1.x
try using :: import tensorflow.compat.v1 as tf
it will work.
Is there an extra step needed after adding this line?
try using :: import tensorflow.compat.v1 as tf
it will work.
I made that change in all .py files inside of
- ./mrcnn
- ./build/lib/mrcnn/
But I think my error message is referencing an instance in
/path/to/conda/env/lib/python3.7/site-packages/mask_rcnn-2.1-py3.7.egg/mrcnn/model.py
I can't figure out a one-step way to make the replacement and have the .ipynb file notice it.
Is there an extra step needed after adding this line?
try using :: import tensorflow.compat.v1 as tf it will work.
I made that change in all .py files inside of
- ./mrcnn
- ./build/lib/mrcnn/
But I think my error message is referencing an instance in
/path/to/conda/env/lib/python3.7/site-packages/mask_rcnn-2.1-py3.7.egg/mrcnn/model.py
I can't figure out a one-step way to make the replacement and have the .ipynb file notice it.
did you solve?
I solved the issue by,
-Navigating to, "/usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py".
- Then, replace tensorflow import with i -import tensorflow.compat.v1 as tf -tf.compat.v1.disable_eager_execution()
- Now, on line 442 of tensorflow_backend.py: change the hyperparameter dtype from None to tf.float32
Let me know if error still persists...!
How can i solve this problem: AttributeError: module 'tensorflow' has no attribute 'log' tensorflow 1.14.0 keras 2.2.4
@lichq try tf.math.log instead of tf.log
Saya memecahkan masalah dengan,
-Navigasi ke, "/usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py".
- Kemudian, ganti impor tensorflow dengan i -import tensorflow.compat.v1 sebagai tf -tf.compat.v1.disable_eager_execution()
- Sekarang, pada baris 442 dari tensorflow_backend.py: ubah hyperparameter dtype dari None menjadi tf.float32
Beri tahu saya jika kesalahan masih berlanjut...!
why on line 442 in my tensorflow there is no syntax dtype = None?