title: TF: Model SubClassing | AttributionError: 'NoneType' object has no attribute 'compile'
body: <p>I'm trying to implement sub-classing for model definition in <code>tf.keras</code> in following way and facing following attribution error.</p>
  <pre class="lang-py prettyprint-override"><code>def my_model(Model):
      def __init__(self, dim):
          super(my_model, self).__init__(**kwargs)
          self.efnet  = efn.EfficientNetB0(input_shape=(dim, 3), include_top = False, weights = 'imagenet')
          self.gap    = L.GlobalAveragePooling2D()
          self.bn     = L.BatchNormalization()
          self.denseA = L.Dense(784, activation='relu', name = 'dense_A')
          self.out    = L.Dense(1, activation='sigmoid')
      
      def call(self, inputs):
          x     = self.efnet(inputs)
          x_gap = self.gap(x)
          bn    = self.bn(x_gap)
          den_A = self.denseA(bn)
          drop  = self.drop(den_A)
          return self.out(drop)
  
  dim = (124,124)
  model = my_model((dim)
  </code></pre>
  <h3>Error</h3>
  <pre><code>---------------------------------------------------------------------------
  AttributeError                            Traceback (most recent call last)
  &lt;ipython-input-3-e8086e70a144&gt; in &lt;module&gt;()
       27 dim = (124,124)
       28 model = my_model(dim)
  ---&gt; 29 model.compile(
       30     optimizer='adam',
       31     loss = 'binary_crossentropy',
  
  AttributeError: 'NoneType' object has no attribute 'compile'
  </code></pre>
  <p><strong>Environment</strong></p>
  <pre><code>OS: Windows OS
  TF Ver. tf 2.1
  </code></pre>
  <p><strong>Reproducibility</strong>
  Here is the reproducible code in <a href="https://colab.research.google.com/gist/ravikyram/f8f3165fa91902706788d3a040f3bf98/untitled869.ipynb" rel="nofollow noreferrer">colab</a>.</p>
  <hr />
  <h3>TIA</h3>