how to use multiple model on TensorFlow 2.8

118 Views Asked by At

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.
1

There are 1 best solutions below

0
On

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