Mask_RCNN icon indicating copy to clipboard operation
Mask_RCNN copied to clipboard

Update model.py

Open Emmaka9 opened this issue 1 year ago • 0 comments

The bahavior of Lambda layer of Keras in Tensorflow 2.X was changed from Tensorflow 1.X. In Keras in Tensorflow 1.X, all tf.Variable and tf.get_variable are automatically tracked into the layer.weights via variable creator context so they receive gradient and trainable automatically. Such approach has problem with auto graph compilation that convert Python code into Execution Graph in Tensorflow 2.X so it is removed and now Lambda layer has the code to check for variable creation and raise the error as you see. In short, Lambda layer in Tensorflow 2.X has to be stateless. If you want to create variable, the correct way in Tensorflow 2.X is to subclass layer class and add trainable weight as a class member.

Ref: https://stackoverflow.com/questions/65073434/why-keras-lambda-layer-cause-problem-mask-rcnn

Emmaka9 avatar Feb 19 '24 10:02 Emmaka9