When to use Layers or Model as parent class

I’m bit confused about when to inherit custom class from Layers and Model.
Like in this image, one time class is inherited from Layers and other time it has been inherited from Model. Or I can use Model every time.

Depends on what you are building, if its a layer you should inherit properties from Layers, if its a model then it sensical from Model class.

Yes sir, this is exactly what has been taught by Laurance sir. My question is : I am bit confused whether in the second image it is a layer or model, because Identity Block is a layer but we have inherited the properties of Model. Please calrify my doubt.

Yes this is good link to check out Layers and model. Basically if it inherits from model its a model with more relevant properties to models.

I guess I got the answer from this line :

  • A layer takes in a tensor and give out a tensor which is a result of some tensor operations
  • A model is a composition of multiple layers.

Thanks a lot @gent.spah for your time and helping me for solving my doubt. :smile:


@gent.spah is it fair to say this type of usage would only be chosen if you want to be able to do Model-like things on the IdentityBlock? compile(), fit(), evaluate() etc? Otherwise, if you just want a named collection of Layers, you could just build a function and call it when you want to instantiate that block. Did I miss something?

Yeah I guess so, when you inherit from the model you would have more relevant properties to the model class.