title: Unable to understand the behavior of method `build` in tensorflow keras layers (tf.keras.layers.Layer)
body: <p>Layers in tensorflow keras have a method <code>build</code> that is used to defer the weights creation to a time when you have seen what the input is going to be. <a href="https://www.tensorflow.org/api_docs/python/tf/keras/layers/Layer#build" rel="nofollow noreferrer">a layer's build method</a></p>
  
  <p>I have a few questions i have not been able to find the answer of:</p>
  
  <ol>
  <li><a href="https://www.tensorflow.org/guide/keras/custom_layers_and_models#layers_are_recursively_composable" rel="nofollow noreferrer">here</a> it is said that 
  
  <blockquote>
    <p>If you assign a Layer instance as attribute of another Layer, the outer layer will start tracking the weights of the inner layer.</p>
  </blockquote></li>
  </ol>
  
  <p>What does it mean to track the weights of a layer?</p>
  
  <ol start="2">
  <li>The same link also mentions that 
  
  <blockquote>
    <p>We recommend creating such sublayers in the <strong>init</strong> method (since the sublayers will typically have a build method, they will be built when the outer layer gets built).</p>
  </blockquote></li>
  </ol>
  
  <p>Does it mean that while running the <code>build</code> method of child class (self), there will an iteration through all the attributes of <code>self</code> and whichever are found to be subclassed from (instances of) <code>tf.keras.layer.Layer</code> will have their <code>build</code> methods run automatically?</p>
  
  <ol start="3">
  <li>I can run this code:</li>
  </ol>
  
  <pre><code>class Net(tf.keras.Model):
    """A simple linear model."""
  
    def __init__(self):
      super(Net, self).__init__()
      self.l1 = tf.keras.layers.Dense(5)
    def call(self, x):
      return self.l1(x)
  
  net = Net()
  print(net.variables)
  </code></pre>
  
  <p>But not this:</p>
  
  <pre><code>class Net(tf.keras.Model):
    """A simple linear model."""
  
    def __init__(self):
      super(Net, self).__init__()
      self.l1 = tf.keras.layers.Dense(5)
    def build(self,input_shape):
      super().build()
    def call(self, x):
      return self.l1(x)
  
  net = Net()
  print(net.variables)
  </code></pre>
  
  <p>why?</p>