"Invalid argument: You must feed a value for placeholder tensor **" Is Displayed During Calibration

Symptom

In the post-training quantization scenario, when the input and output of the original model are used for inference after the model is modified, an error message is displayed, indicating that a placeholder must be provided for data input. As a result, the calibration process is interrupted. The message is as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
Traceback (most recent call last):
  File "xxx/site-packages/tensorflow_core/python/client/session.py", line 1365, in _do_call
    return fn(*args)
  File "xxx/site-packages/tensorflow_core/python/client/session.py", line 1350, in _run_fn
    target_list, run_metadata)
  File "xxx/site-packages/tensorflow_core/python/client/session.py", line 1443, in _call_tf_sessionrun
    run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found.
  (0) Invalid argument: You must feed a value for placeholder tensor 'input' with dtype float and shape [1,32,32,10]
         [[{{node input}}]]
         [[ConstantFoldingCtrl/conv1/search_n_quant/search_n_quant_SEARCHN/cond/Switch_0/_22]]
  (1) Invalid argument: You must feed a value for placeholder tensor 'input' with dtype float and shape [1,32,32,10]
         [[{{node input}}]]

Possible Cause

When quantize_model is called to process your graph, operations such as fusion and replacement are performed, which may change the output node of your model, for example, connecting the output node to a placeholder.

Solution

When quantize_model is called, a warning message will display upon output node changes. During the calibration, modify the output node as prompted.