title: Keras AttributeError: 'Functional' object has no attribute 'shape'
body: <p>Trying to add Densenet121 functional block to the model.
  I need Keras model to be written in this format, not using</p>
  <pre><code>model=Sequential() 
  model.add()
  </code></pre>
  <p>method
  What's wrong the function, build_img_encod</p>
  <pre><code>---------------------------------------------------------------------------
  AttributeError                            Traceback (most recent call last)
  &lt;ipython-input-62-69dd207148e0&gt; in &lt;module&gt;()
  ----&gt; 1 x = build_img_encod()
  
  3 frames
  /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/input_spec.py in assert_input_compatibility(input_spec, inputs, layer_name)
      164         spec.min_ndim is not None or
      165         spec.max_ndim is not None):
  --&gt; 166       if x.shape.ndims is None:
      167         raise ValueError('Input ' + str(input_index) + ' of layer ' +
      168                          layer_name + ' is incompatible with the layer: '
  
  AttributeError: 'Functional' object has no attribute 'shape'
  </code></pre>
  <pre><code>def build_img_encod( ):
      base_model = DenseNet121(input_shape=(150,150,3),
                                   include_top=False,
                                   weights='imagenet')
      for layer in base_model.layers:
              layer.trainable = False
      flatten = Flatten(name=&quot;flatten&quot;)(base_model)
      img_dense_encoder = Dense(1024, activation='relu',name=&quot;img_dense_encoder&quot;, kernel_regularizer=regularizers.l2(0.0001))(flatten)
      model = keras.models.Model(inputs=base_model, outputs = img_dense_encoder)
      return model
  </code></pre>