See also:

  

      github.com/keras-team/keras-cv
  

  
    
  
	  
  

  
    
      Standardized / preferred way to implement blocks and models. 1
    

    
      
        opened 
        
          
        
        Jan 27, 2022
      
      


      
        
          
          sebastian-sz
        
      
    

    
    
  


  
    Given the models requirements are being gathered in the [discussion](https://git…hub.com/keras-team/keras-cv/discussions/52), is there a preferred way to implement them?

There are multiple ways, to implement blocks and models:
1. `keras.applications` way -> Models and blocks are functional [Example](https://github.com/keras-team/keras/blob/2c48a3b38b6b6139be2da501982fd2f61d7d48fe/keras/applications/resnet.py#L440-L459).
2. Model Garden way -> Model is [functional](https://github.com/tensorflow/models/blob/c8a402fc7fc0cc391a9e3ac56fb7b3ea6f9d202e/official/vision/beta/modeling/backbones/resnet.py#L99), but blocks are [layer subclasses](https://github.com/tensorflow/models/blob/c8a402fc7fc0cc391a9e3ac56fb7b3ea6f9d202e/official/vision/beta/modeling/layers/nn_blocks.py#L56). (even though the model is a direct subclass, it does not override call method).
3. Blocks are layer subclasses, and models are model subclasses of `keras.layers.Layer` and `keras.Model` respectively. Both implement `call` method.

Each way has it's own benefits and drawbacks. Is one of the above preferred? Or maybe something entirely different?