title: Keras Concatenate: "Nonetype" object is not subscriptable
body: <p>I am trying to concatenate the outputs of two or more models.</p>
  <p><strong>Code:</strong></p>
  <pre><code>import efficientnet.tfkeras as efn
  
  def build_model(model_name=&quot;efficientnet_B0&quot;, dim=128,
                  normalize_features=True, return_feature_model=False, 
                  inp_layer=None):
      
      def get_efficientnet(effnet_model):
          effnet_model = int(effnet_model)
          EFNS = [efn.EfficientNetB0, efn.EfficientNetB1,
                  efn.EfficientNetB2, efn.EfficientNetB3, 
                  efn.EfficientNetB4, efn.EfficientNetB5,
                  efn.EfficientNetB6, efn.EfficientNetB7,]
          return EFNS[effnet_model]
  
      model_dict = {
          &quot;efficientnet&quot;: get_efficientnet,
          &quot;resnet50&quot;: tf.keras.applications.ResNet50,
          &quot;vgg19&quot;: tf.keras.applications.VGG19,
          &quot;Xception&quot;: tf.keras.applications.Xception,
      }   
  
  
      # For Image Input
      if model_name.find('efficientnet') != -1:
          base = model_dict['efficientnet'](model_name[-1])(input_shape=(dim,dim,3),
                                                            weights='imagenet',
                                                            include_top=False)(inp_layer)
      else:
          base = model_dict[model_name](input_shape=(dim,dim,3),
                                        weights='imagenet',
                                        include_top=False)(inp_layer)
      
      pooling_layer = keras.layers.GlobalAveragePooling2D()(base)
      normalized_feature = keras.layers.BatchNormalization(name=&quot;norm_featvec&quot;)(pooling_layer)
      output = keras.layers.Dense(1,activation='sigmoid')(pooling_layer)
      
      if normalize_features:
          feat_output = normalized_feature
      else:
          feat_output = pooling_layer
              
      if return_feature_model:
          featext_model = keras.Model(inputs=[img_inp], outputs=[feat_output])
      model = keras.Model(inputs=[img_inp], outputs=[output])
  
      if return_feature_model:
          return model, featext_model
      else:
          return model
  
  
  
  def get_complete_model(featvec_model_paths, dim=384):
      input_layer = keras.layers.Input(shape=(dim, dim, 3), name=&quot;img_input&quot;)
      models = list()
      
      for model_path in featvec_model_paths:
          model_name = os.path.basename(model_path)[5:-5]
          _, featvec_model = build_model(model_name=model_name, dim=dim,
                                         return_feature_model=True,
                                         inp_layer=input_layer)
          featvec_model.load_weights(model_path)
          featvec_model.trainable = False
          models.append(featvec_model)
          
      concat_layer = keras.layers.Concatenate()(models)
      dense_1 = keras.layers.Dense(4096, activation=&quot;selu&quot;)(concat_layer)
      dense_2 = keras.layers.Dense(2048, activation=&quot;selu&quot;)(dense_1)
      dense_3 = keras.layers.Dense(1024, activation=&quot;selu&quot;)(dense_2)
      output_layer = keras.layers.Dense(1, activation=&quot;sigmoid&quot;)(dense_3)
      
      model = keras.Model(inputs=[input_layer], outputs=[output_layer])
      
      model.compile(loss=keras.losses.BinaryCrossentropy(),
                    optimizer=keras.optimizers.Nadam(),
                    metrics=['AUC'])
      return model
  </code></pre>
  <p><code>featvec_model_paths</code> in <code>get_complete_model</code> are paths to weight files.</p>
  <p><strong>Execution Line:</strong></p>
  <pre><code>featvec_paths = ['feat_efficientnet_b3_0.h5',
                   'feat_efficientnet_b3_1.h5',
                   'feat_efficientnet_b4_0.h5',
                   'feat_efficientnet_b4_1.h5']
  final_model, featvec_model = get_complete_model(featvec_paths, dim=384)
  </code></pre>
  <p>You can run the code by commenting <code>featvec_model.load_weights(model_path)</code>.</p>
  <p><strong>Error:</strong></p>
  <pre><code>TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-104-76ecd46bf20d&gt; in &lt;module&gt;
  ----&gt; 1 final_model, featvec_model = get_complete_model(featvec_paths, dim=384)
  
  &lt;ipython-input-103-d92456535b41&gt; in get_complete_model(featvec_model_paths, dim)
       17         #print(models)
       18 
  ---&gt; 19     concat_layer = keras.layers.Concatenate()(models)
       20     dense_1 = keras.layers.Dense(4096, activation=&quot;selu&quot;)(concat_layer)
       21     dense_2 = keras.layers.Dense(2048, activation=&quot;selu&quot;)(dense_1)
  
  /opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py in __call__(self, *args, **kwargs)
     1006       with ops.name_scope_v2(name_scope):
     1007         if not self.built:
  -&gt; 1008           self._maybe_build(inputs)
     1009 
     1010         with autocast_variable.enable_auto_cast_variables(
  
  /opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py in _maybe_build(self, inputs)
     2708         # operations.
     2709         with tf_utils.maybe_init_scope(self):
  -&gt; 2710           self.build(input_shapes)  # pylint:disable=not-callable
     2711       # We must set also ensure that the layer is marked as built, and the build
     2712       # shape is stored since user defined build functions may not be calling
  
  /opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/utils/tf_utils.py in wrapper(instance, input_shape)
      270     if input_shape is not None:
      271       input_shape = convert_shapes(input_shape, to_tuples=True)
  --&gt; 272     output_shape = fn(instance, input_shape)
      273     # Return shapes from `fn` as TensorShapes.
      274     if output_shape is not None:
  
  /opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/layers/merge.py in build(self, input_shape)
      490   def build(self, input_shape):
      491     # Used purely for shape validation.
  --&gt; 492     if not isinstance(input_shape[0], tuple) or len(input_shape) &lt; 2:
      493       raise ValueError('A `Concatenate` layer should be called '
      494                        'on a list of at least 2 inputs')
  
  TypeError: 'NoneType' object is not subscriptable
  </code></pre>
  <p>I am passing a list of models to the concatenation class object. I also tried appending only the last layers of each model:
  <code>models.append(featvec_model.layers[-1])</code> but this also gave the same error.</p>