title: Found unexpected instance while processing input tensors for keras functional model - Keras, Tensorflow
body: <p>I'm basically super new to the ML and image recognition topics and what I'm trying to do currently, in order to learn, is to replicate and just make the online tutorial from kaggle.com (<a href="https://www.kaggle.com/pavansanagapati/simple-tutorial-on-object-recognition" rel="nofollow noreferrer">https://www.kaggle.com/pavansanagapati/simple-tutorial-on-object-recognition</a>) work on my desktop PyCharm app.</p>
  <p>I have a serious (at least for a beginner) problem, that I've been stuck on for some time. Below you can see an error that I'm dealing with right now.</p>
  <pre><code>Traceback (most recent call last):
  File &quot;C:\Users\blahblah\main.py&quot;, line 195, in &lt;module&gt;
  activations = get_featuremaps(cnn_model, int(layer_num), test_img)
  File &quot;C:\Users\blahblah\main.py&quot;, line 187, in get_featuremaps
  get_activations = K.function([cnn_model.layers[0].input, K.learning_phase()],
  File &quot;C:\Users\blahblah\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\backend.py&quot;, line 4229, in function
  model = models.Model(inputs=inputs, outputs=outputs)
  File &quot;C:\Users\blahblah\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\python\training\tracking\base.py&quot;, line 530, in _method_wrapper
  result = method(self, *args, **kwargs)
  File &quot;C:\Users\blahblah\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\engine\functional.py&quot;, line 143, in __init__
  if not all([functional_utils.is_input_keras_tensor(t)
  File &quot;C:\Users\blahblah\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\engine\functional.py&quot;, line 143, in &lt;listcomp&gt;
  if not all([functional_utils.is_input_keras_tensor(t)
  File &quot;C:\Users\blahblah\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\engine\functional_utils.py&quot;, line 47, in is_input_keras_tensor
  raise ValueError(_KERAS_TENSOR_TYPE_CHECK_ERROR_MSG.format(tensor))
  ValueError: Found unexpected instance while processing input tensors for keras functional model. Expecting KerasTensor which is from tf.keras.Input() or output from keras layer call(). Got: 0
  </code></pre>
  <p>And that's the problematic code.</p>
  <pre><code>def get_featuremaps(cnn_model, layer_idx, X_batch):
      get_activations = K.function([cnn_model.layers[0].input, K.learning_phase()],
                                   [cnn_model.layers[layer_idx].output, ])
      activations = get_activations([X_batch, 0])
      return activations
  </code></pre>
  <p>I would greatly appreciate all answers and ideas on how to deal with that. Cheers!</p>