Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
891 views
in Technique[技术] by (71.8m points)

python - error with lambda layer in tensorflow 2.0 using mask rcnn

I am trying to use the matterport code for Mask-RCNN of as modified for tensorflow 2.0 in [https://github.com/ahmedfgad/Mask-RCNN-TF2][1]

but i am getting this error:

Traceback (most recent call last):
  File "samples/balloon/tumour.py", line 386, in <module>
    model = modellib.MaskRCNN(mode="training", config=config,
  File "/usr/local/lib/python3.8/dist-packages/mask_rcnn_tf2-1.0-py3.8.egg/mrcnn/model.py", line 1837, in __init__
  File "/usr/local/lib/python3.8/dist-packages/mask_rcnn_tf2-1.0-py3.8.egg/mrcnn/model.py", line 1934, in build
  File "/home/tzikos/.local/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py", line 922, in __call__
    outputs = call_fn(cast_inputs, *args, **kwargs)
  File "/home/tzikos/.local/lib/python3.8/site-packages/tensorflow/python/keras/layers/core.py", line 889, in call
    self._check_variables(created_variables, tape.watched_variables())
  File "/home/tzikos/.local/lib/python3.8/site-packages/tensorflow/python/keras/layers/core.py", line 916, in _check_variables
    raise ValueError(error_str)
ValueError: 
The following Variables were created within a Lambda layer (anchors)
but are not tracked by said layer:
  <tf.Variable 'anchors/Variable:0' shape=(2, 261888, 4) dtype=float32>
The layer cannot safely ensure proper Variable reuse across multiple
calls, and consquently this behavior is disallowed for safety. Lambda
layers are not well suited to stateful computation; instead, writing a
subclassed Layer is the recommend way to define layers with
Variables.

Now i tried out this solutions: [https://stackoverflow.com/questions/65073434/why-keras-lambda-layer-cause-problem-mask-rcnn][2] and here:[https://github.com/matterport/Mask_RCNN/issues/1930][3] where they modify a specific line.

I changed that in both instances of model.py i found in the directory of mask-rcnn but i could not find the case specified in the usr/local/bin/.... . It errored that it did not recognize the mrcnn directory.

The error persists and i cannot find or think of anything else to use . Can you please help me ? [1]: https://github.com/ahmedfgad/Mask-RCNN-TF2 [2]: Why Keras Lambda-Layer cause problem Mask_RCNN? [3]: https://github.com/matterport/Mask_RCNN/issues/1930

question from:https://stackoverflow.com/questions/65860271/error-with-lambda-layer-in-tensorflow-2-0-using-mask-rcnn

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...