Residual network in Tensorflow advance Techniques

Sir in the code snippet of Dense Residual in Slide there is a class which inherits Layer class but then why we did not add build method in it as we did in Custom Layers

Hello Divyanshu,

Your question is a bit unclear. Can you share the snippet you want to compare with and have doubt with, so others can understand and explain with a proper reasoning.


1 Like

Hi @Divyanshu_Gupta1,

Build method will run when your instance is created, we will use this method to specify our local input states.
Actually, the build method is not mandatory for the custom layer. It can optionally be used to define a custom layer class to create a layer’s weight for the first time. If the shape of the input tensor is known, can define the layer’s weight at initialization, then we can ignore the build method. But to create layers dynamically we can use the build method. This is useful when the layer’s shape depends on the shape of inputs, and allows more flexibility in constructing the layer. Also, the build method advantage is that it enables late variable creation based on the shape of the input the layer will operate on.


1 Like

Can you share the link to the slides?