你推荐如何使用Tensorflow 2.8的多个模型
我曾经使用Tensorflow 1.14。如果我可以通过范围指定模型
with graph.as_default():
K.set_session(session)
model.predict(input)
但是在tensorflow 2.8上我不知道如何使用多个模型
你推荐它吗?
更新我的问题很困惑
我通过功能API tensorflow和load_weights来创建模型当我用特定的模型来预测时,我得到了一些错误
File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.8/site-packages/keras/engine/training_v1.py", line 970, in predict
return func.predict(
File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.8/site-packages/keras/engine/training_arrays_v1.py", line 700, in predict
return predict_loop(
File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.8/site-packages/keras/engine/training_arrays_v1.py", line 377, in model_iteration
batch_outs = f(ins_batch)
File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.8/site-packages/keras/backend.py", line 4275, in __call__
fetched = self._callable_fn(*array_vals,
File "/opt/homebrew/Caskroom/miniforge/base/envs/myenv/lib/python3.8/site-packages/tensorflow/python/client/session.py", line 1480, in __call__
ret = tf_session.TF_SessionRunCallable(self._session._session,
tensorflow.python.framework.errors_impl.FailedPreconditionError: 2 root error(s) found.
(0) FAILED_PRECONDITION: Could not find variable conv2d_3/kernel. This could mean that the variable has been deleted. In TF1, it can also mean the variable is uninitialized. Debug info: container=localhost, status error message=Container localhost does not exist. (Could not find resource: localhost/conv2d_3/kernel)
[[{{node conv2d_3/Conv2D/ReadVariableOp}}]]
[[conv2d_7/Conv2D/ReadVariableOp/_19]]
(1) FAILED_PRECONDITION: Could not find variable conv2d_3/kernel. This could mean that the variable has been deleted. In TF1, it can also mean the variable is uninitialized. Debug info: container=localhost, status error message=Container localhost does not exist. (Could not find resource: localhost/conv2d_3/kernel)
[[{{node conv2d_3/Conv2D/ReadVariableOp}}]]
0 successful operations.
0 derived errors ignored.
我通过将macbook (m1芯片)上的运行更改为在我的pc上运行来解决这个问题
感谢大家观看和评论我的问题