我正在尝试运行中提到的sentdex提供的代码https://pythonprogramming.net/reinforcement-learning-self-driving-autonomous-cars-carla-python/.
规格:-
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:UsershrishAppDataLocalProgramsPythonPython37libsite-packagestensorflowpythonopsresource_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:UsershrishAppDataLocalProgramsPythonPython37libsite-packagestensorflowpythonkerasutilslosses_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:UsershrishAppDataLocalProgramsPythonPython37libsite-packagestensorflowpythonopsmath_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:UsershrishAppDataLocalProgramsPythonPython37libthreading.py", line 926, in _bootstrap_inner
self.run()
File "C:UsershrishAppDataLocalProgramsPythonPython37libthreading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "D:My_CodesFOR_CARLApart3.py", line 262, in train_in_loop
self.model.fit(X,y, verbose=False, batch_size=1)
File "C:UsershrishAppDataLocalProgramsPythonPython37libsite-packagestensorflowpythonkerasenginetraining.py", line 880, in fit
validation_steps=validation_steps)
File "C:UsershrishAppDataLocalProgramsPythonPython37libsite-packagestensorflowpythonkerasenginetraining_arrays.py", line 329, in model_iteration
batch_outs = f(ins_batch)
File "C:UsershrishAppDataLocalProgramsPythonPython37libsite-packagestensorflowpythonkerasbackend.py", line 3076, in __call__
run_metadata=self.run_metadata)
File "C:UsershrishAppDataLocalProgramsPythonPython37libsite-packagestensorflowpythonclientsession.py", line 1439, in __call__
run_metadata_ptr)
File "C:UsershrishAppDataLocalProgramsPythonPython37libsite-packagestensorflowpythonframeworkerrors_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}}]]
经过几天的研究,我发现资源没有初始化,因此它说var不存在。因此,我发现了几行粘贴在graph.as_default((之后和保存模型之前的代码。这些是代码行:-
session = keras.backend.get_session()
init = tf.global_variables_initializer()
session.run(init)
我相信这些行能够使事情正常工作,因为它能够初始化所有变量。
使用:
- TensorFlow 1.14版
- numpy版本1.16.4
- Keras 2.2.5版
对我有用。
它可能与GPU资源有关。我做了
pip install tensorflow-gpu==1.15.5
它变成了另一个错误。我以前没有安装tensorflow gpu。