如何在Tensorflow 2.8上使用多个模型
您是否推荐如何在
Tensorflow 1.14上使用多个型号进行Tensorflow 2.8。我可以按范围进行特定的模型
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.
do you recommend how to use multiple model for Tensorflow 2.8
I used to on Tensorflow 1.14. it i can specific model by scope
with graph.as_default():
K.set_session(session)
model.predict(input)
but on tensorflow 2.8 i don't know how to use multiple model
do you recommend it.
update
my question is confused
i create model by functional API tensorflow and load_weights to model
and when i specific model to predict i got some error
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过从MacBook(M1芯片)上的Run Run Conn在我的PC上进行的更改解决了我的
问题
i solved my problem by change from run on macbook (m1 chip) to run on my pc
thanks for everyone view and comments my question