title: Error when Loading a .pb Tensorflow Model
body: <p>I created a tensorflow model on a Windows 10 machine and saved it using:</p>
  <pre><code>model.save('myfolder')
  </code></pre>
  <p>Inside the folder <code>myfolder</code> I get:</p>
  <pre><code>- saved_model.pb
  - Variables folder
  - Assets folder
  </code></pre>
  <p>Now I'm trying to load the model in a Linux machine, so I'm passing the folder path as the model path to load it:</p>
  <pre><code>model = tf.keras.models.load_model('myfolder')
  </code></pre>
  <p>It actually detects the model but throw this huge error:</p>
  <pre><code>2020-09-27 18:43:57.980054: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond/while' has 13 outputs but the _output_shapes attribute specifies shapes for 44 outputs. Output shapes may be inaccurate.
  2020-09-27 18:44:02.211495: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond/while' has 13 outputs but the _output_shapes attribute specifies shapes for 44 outputs. Output shapes may be inaccurate.
  2020-09-27 18:44:02.376792: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond' has 5 outputs but the _output_shapes attribute specifies shapes for 45 outputs. Output shapes may be inaccurate.
  2020-09-27 18:44:16.361762: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond' has 5 outputs but the _output_shapes attribute specifies shapes for 45 outputs. Output shapes may be inaccurate.
  2020-09-27 18:44:18.184022: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond/while' has 13 outputs but the _output_shapes attribute specifies shapes for 44 outputs. Output shapes may be inaccurate.
  2020-09-27 18:44:18.331177: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond' has 5 outputs but the _output_shapes attribute specifies shapes for 45 outputs. Output shapes may be inaccurate.
  2020-09-27 18:44:19.087747: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond/while' has 13 outputs but the _output_shapes attribute specifies shapes for 44 outputs. Output shapes may be inaccurate.
  2020-09-27 18:44:22.933245: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond/while' has 13 outputs but the _output_shapes attribute specifies shapes for 44 outputs. Output shapes may be inaccurate.
  2020-09-27 18:44:23.074951: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond' has 5 outputs but the _output_shapes attribute specifies shapes for 45 outputs. Output shapes may be inaccurate.
  2020-09-27 18:44:28.451176: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond/while' has 13 outputs but the _output_shapes attribute specifies shapes for 44 outputs. Output shapes may be inaccurate.
  2020-09-27 18:44:28.597107: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond' has 5 outputs but the _output_shapes attribute specifies shapes for 45 outputs. Output shapes may be inaccurate.
  2020-09-27 18:44:33.579605: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond/while' has 13 outputs but the _output_shapes attribute specifies shapes for 44 outputs. Output shapes may be inaccurate.
  2020-09-27 18:44:33.742273: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond' has 5 outputs but the _output_shapes attribute specifies shapes for 45 outputs. Output shapes may be inaccurate.
  2020-09-27 18:44:51.043732: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond/while' has 13 outputs but the _output_shapes attribute specifies shapes for 44 outputs. Output shapes may be inaccurate.
  2020-09-27 18:44:57.151346: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond' has 5 outputs but the _output_shapes attribute specifies shapes for 45 outputs. Output shapes may be inaccurate.
  2020-09-27 18:45:00.168905: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond/while' has 13 outputs but the _output_shapes attribute specifies shapes for 44 outputs. Output shapes may be inaccurate.
  2020-09-27 18:45:00.312153: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond' has 5 outputs but the _output_shapes attribute specifies shapes for 45 outputs. Output shapes may be inaccurate.
  2020-09-27 18:45:01.051383: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond/while' has 13 outputs but the _output_shapes attribute specifies shapes for 44 outputs. Output shapes may be inaccurate.
  2020-09-27 18:45:01.190471: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond' has 5 outputs but the _output_shapes attribute specifies shapes for 45 outputs. Output shapes may be inaccurate.
  2020-09-27 18:45:01.395016: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond/while' has 13 outputs but the _output_shapes attribute specifies shapes for 44 outputs. Output shapes may be inaccurate.
  2020-09-27 18:45:01.542457: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond' has 5 outputs but the _output_shapes attribute specifies shapes for 45 outputs. Output shapes may be inaccurate.
  2020-09-27 18:45:05.023475: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond/while' has 13 outputs but the _output_shapes attribute specifies shapes for 44 outputs. Output shapes may be inaccurate.
  2020-09-27 18:45:05.235829: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond' has 5 outputs but the _output_shapes attribute specifies shapes for 45 outputs. Output shapes may be inaccurate.
  2020-09-27 18:45:05.568045: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond' has 5 outputs but the _output_shapes attribute specifies shapes for 45 outputs. Output shapes may be inaccurate.
  2020-09-27 18:45:06.300144: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond/while' has 13 outputs but the _output_shapes attribute specifies shapes for 44 outputs. Output shapes may be inaccurate.
  2020-09-27 18:45:06.439828: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond' has 5 outputs but the _output_shapes attribute specifies shapes for 45 outputs. Output shapes may be inaccurate.
  2020-09-27 18:45:11.585829: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond/while' has 13 outputs but the _output_shapes attribute specifies shapes for 44 outputs. Output shapes may be inaccurate.
  2020-09-27 18:45:11.729289: W tensorflow/core/graph/graph_constructor.cc:772] Node 'cond' has 5 outputs but the _output_shapes attribute specifies shapes for 45 outputs. Output shapes may be inaccurate.
  Traceback (most recent call last):
    File &quot;main.py&quot;, line 95, in &lt;module&gt;
      model = tf.keras.models.load_model('model')
    File &quot;/home/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/saving/save.py&quot;, line 150, in load_model
      return saved_model_load.load(filepath, compile)
    File &quot;/home/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/saving/saved_model/load.py&quot;, line 89, in load
      model = tf_load.load_internal(path, loader_cls=KerasObjectLoader)
    File &quot;/home/.local/lib/python3.7/site-packages/tensorflow_core/python/saved_model/load.py&quot;, line 541, in load_internal
      export_dir)
    File &quot;/home/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/saving/saved_model/load.py&quot;, line 118, in __init__
      super(KerasObjectLoader, self).__init__(*args, **kwargs)
    File &quot;/home/.local/lib/python3.7/site-packages/tensorflow_core/python/saved_model/load.py&quot;, line 121, in __init__
      self._load_all()
    File &quot;/home/.local/lib/python3.7/site-packages/tensorflow_core/python/saved_model/load.py&quot;, line 239, in _load_all
      node, setter = self._recreate(proto)
    File &quot;/home/.local/lib/python3.7/site-packages/tensorflow_core/python/saved_model/load.py&quot;, line 322, in _recreate
      return factory[kind]()
    File &quot;/home/.local/lib/python3.7/site-packages/tensorflow_core/python/saved_model/load.py&quot;, line 309, in &lt;lambda&gt;
      &quot;user_object&quot;: lambda: self._recreate_user_object(proto.user_object),
    File &quot;/home/.local/lib/python3.7/site-packages/tensorflow_core/python/saved_model/load.py&quot;, line 328, in _recreate_user_object
      return self._recreate_base_user_object(proto)
    File &quot;/home/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/saving/saved_model/load.py&quot;, line 216, in _recreate_base_user_object
      return revived_cls._init_from_metadata(metadata)  # pylint: disable=protected-access
    File &quot;/home/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/saving/saved_model/load.py&quot;, line 297, in _init_from_metadata
      revived_obj = cls(**init_args)
    File &quot;/home/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/input_layer.py&quot;, line 86, in __init__
      batch_size = batch_input_shape[0]
  KeyError: 0
  </code></pre>
  <p>I have already searched in Tensorflow issues from GitHub but I haven't found anythin interesting yet. I saw a <a href="https://stackoverflow.com/a/63321129/13071340">SO answer</a> recommending create a new model with the weights of the loaded one but I can't even do it because I get the error while the loading.</p>