I’ve made a custom layer with the class method and when I’m trying to call the class it shows this error message :
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-143-9ad907fef5b1> in <module>
----> 1 model.layers()
AttributeError: 'lane_detection_network' object has no attribute 'layers'
the code is here:
class lane_detection_network(tf.Module):
def __init__(self):
super(lane_detection_network, self).__init__()
self.resizing = resize_layer(3, 128)
#feature extraction
self.layer1 = hourglass_block(128, 128)
self.layer2 = hourglass_block(128, 128)
def call(self, inputs):
#feature extraction
out = self.resizing(inputs)
result1, out = self.layer1(out)
result2, out = self.layer2(out)
return [result1, result2]
CodePudding user response:
I believe this is because tf.Module
is a very basic class - it does not have layers
. Also, you have not explicitly set them.
Is there a reason you are not using Keras? Otherwise, this TF guide demonstrates exactly how to achieve what you want. Make sure you know the difference between a Layer
and a Model
and then it should be straightforward to get the desired result.