1

我正在尝试运行https://pythonprogramming.net/reinforcement-learning-self-driving-autonomous-cars-carla-python/中提到的 sentdex 给出的代码。

规格:-

Windows 10、卡拉 0.9.5、Python 3.7.5、Tensorflow 1.14.0。

我没有使用任何 GPU 版本的 tensorflow。我对代码的导入做了一些改动。当我运行此代码时,我收到 Resource not found 错误。另请注意,如代码中所述,carla 的实例已经在端口 2000 的后台运行。到目前为止,我已经通过更改它们的位置以及安装不同版本的 tensorflow 来使用导入。

进口变化:-

from tensorflow.python.keras.applications.xception import Xception
from tensorflow.python.keras.layers.core import Dense
from tensorflow.python.keras.layers.pooling import GlobalAveragePooling2D
from tensorflow.python.keras.optimizer_v2.adam import Adam
from tensorflow.python.keras.engine.training import Model
from tensorflow.python.keras.callbacks import TensorBoard
from tensorflow.python.keras import backend

错误信息:-

2020-02-20 01:57:14.084452: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
WARNING:tensorflow:From C:\Users\hrish\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py:435: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
WARNING:tensorflow:From C:\Users\hrish\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\keras\utils\losses_utils.py:170: to_float (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.cast instead.
WARNING:tensorflow:From C:\Users\hrish\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\ops\math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.cast instead.
2020-02-20 01:57:32.857485: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block5_sepconv3_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.857488: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block6_sepconv3_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.857487: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block5_sepconv3_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.858212: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block6_sepconv1_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.857489: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block6_sepconv2_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.858627: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block7_sepconv3_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.858846: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block7_sepconv2_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.859316: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block7_sepconv2_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.859587: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block7_sepconv1_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.859854: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block7_sepconv1_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.860144: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block8_sepconv3_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.857797: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block6_sepconv2_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.860702: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block8_sepconv2_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.860974: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block8_sepconv2_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.861245: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block8_sepconv1_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.861525: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block8_sepconv1_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.860418: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block8_sepconv3_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.862156: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block9_sepconv3_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.857490: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block6_sepconv3_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.862761: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block9_sepconv2_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.857727: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block13_sepconv1_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.861867: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block9_sepconv3_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.863594: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block9_sepconv1_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.863874: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block5_sepconv2_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.864148: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block5_sepconv2_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.864422: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block5_sepconv1_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.864696: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block5_sepconv1_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.863333: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block13_sepconv1_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.865253: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block13_sepconv2_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.865530: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block13_sepconv2_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.858415: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block7_sepconv3_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.863040: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block9_sepconv1_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.866358: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block4_sepconv1_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.866635: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block4_sepconv1_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.866907: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block3_sepconv2_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.865804: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block12_sepconv1_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.866094: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block4_sepconv2_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.867732: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block3_sepconv1_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.868010: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block3_sepconv1_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.868295: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block2_sepconv2_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.867185: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block3_sepconv2_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.867513: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block12_sepconv1_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.864973: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block4_sepconv2_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.858011: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block6_sepconv1_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.862487: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block9_sepconv2_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.870065: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block1_conv2_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.868855: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block2_sepconv1_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.869190: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block12_sepconv2_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.869507: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block2_sepconv1_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.869768: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block1_conv2_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.871489: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block14_sepconv2_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.870341: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block1_conv1_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.872050: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block14_sepconv1_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.870908: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block12_sepconv2_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.871215: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block14_sepconv2_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.872874: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block10_sepconv3_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.873155: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block10_sepconv2_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.873430: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block10_sepconv2_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.873705: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block10_sepconv1_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.872604: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block12_sepconv3_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.868587: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block2_sepconv2_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.871769: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block14_sepconv1_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.874838: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/batch_normalization_v1_3/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.875136: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/batch_normalization_v1_2/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.873983: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block10_sepconv1_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.874267: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block12_sepconv3_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.876008: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block11_sepconv1_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.870625: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block1_conv1_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.872324: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block10_sepconv3_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.875455: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/batch_normalization_v1_2/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.875738: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/batch_normalization_v1_1/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.874569: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/batch_normalization_v1_3/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.876297: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block11_sepconv1_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.876570: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/batch_normalization_v1_1/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.878266: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block11_sepconv2_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.877161: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/batch_normalization_v1/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.877435: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block11_sepconv3_bn/beta/class tensorflow::Var does not exist.
2020-02-20 01:57:32.877714: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block11_sepconv3_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.877985: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/block11_sepconv2_bn/gamma/class tensorflow::Var does not exist.
2020-02-20 01:57:32.876877: W tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at resource_variable_ops.cc:260 : Not found: Resource localhost/batch_normalization_v1/gamma/class tensorflow::Var does not exist.
Exception in thread Thread-2:
Traceback (most recent call last):
  File "C:\Users\hrish\AppData\Local\Programs\Python\Python37\lib\threading.py", line 926, in _bootstrap_inner
    self.run()
  File "C:\Users\hrish\AppData\Local\Programs\Python\Python37\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "D:\My_Codes\FOR_CARLA\part3.py", line 262, in train_in_loop
    self.model.fit(X,y, verbose=False, batch_size=1)
  File "C:\Users\hrish\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\keras\engine\training.py", line 880, in fit
    validation_steps=validation_steps)
  File "C:\Users\hrish\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\keras\engine\training_arrays.py", line 329, in model_iteration
    batch_outs = f(ins_batch)
  File "C:\Users\hrish\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\keras\backend.py", line 3076, in __call__
    run_metadata=self.run_metadata)
  File "C:\Users\hrish\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\client\session.py", line 1439, in __call__
    run_metadata_ptr)
  File "C:\Users\hrish\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 528, in __exit__
    c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.FailedPreconditionError: Error while reading resource variable dense/kernel from Container: localhost. This could mean that the variable was uninitialized. Not found: Resource localhost/dense/kernel/class tensorflow::Var does not exist.
     [[{{node dense/MatMul/ReadVariableOp}}]]
4

3 回答 3

2

经过多天的研究,我发现资源没有被初始化,因此它说 var 不存在。因此,我发现在 graph.as_default() 之后和保存模型之前粘贴了几行代码。这些是代码行:-

session = keras.backend.get_session()
init = tf.global_variables_initializer()
session.run(init)

我相信这些行正在使事情正常进行,因为它能够初始化所有变量。

于 2020-03-01T15:21:54.760 回答
2

采用:

  1. TensorFlow 1.14 版
  2. numpy 版本 1.16.4
  3. Keras 版本 2.2.5

它对我有用。

于 2020-06-05T22:59:29.920 回答
0

它可能与GPU资源有关。我做了

pip install tensorflow-gpu==1.15.5 

它变成了一个不同的错误。我之前没有安装 tensorflow-gpu。

于 2022-02-28T23:34:16.330 回答