Hi, I have trained a CNN LSTM model, and used ModelCheckpoint to save the model. Then, I used different codes to freeze this model, then input it to OpenVino to convert as IR. However, problems arise as shown below:
First Code
import tensorflow as tf
from tensorflow.python.framework.convert_to_constants import convert_variables_to_constants_v2
import pdb
new_model = tf.keras.models.load_model('/content/drive/MyDrive/cnnlstm1')
full_model = tf.function(lambda x: new_model(x))
full_model = full_model.get_concrete_function(x=tf.TensorSpec((None,20,64,64,3),'float32'))
forzen_func = convert_variables_to_constants_v2(full_model)
forzen_func.graph.as_graph_def()
layers = [op.name for op in forzen_func.graph.get_operations()]
print("-"*50)
print("Frozen model layers:")
for layer in layers:
print(layer)
print("*"*50)
print("Frozen model input:")
print(forzen_func.inputs)
print("Frozen model output:")
print(forzen_func.outputs)
tf.io.write_graph(
graph_or_graph_def=forzen_func.graph,
logdir="./",
name="testtt.pb",
as_text=False
)
The error output:
RuntimeError: Check 'false' failed at src/frontends/tensorflow/src/frontend.cpp:168:
FrontEnd API failed with GeneralFailure: :
No input is found for node "sequential_1/lstm_1/PartitionedCall/TensorArrayUnstack/TensorListFromTensor" by port 0
Second code
import tensorflow as tf
from tensorflow.python.framework.convert_to_constants import convert_variables_to_constants_v2
model = tf.saved_model.load('/content/drive/MyDrive/cnnlstm1')
frozen_func = convert_variables_to_constants_v2(model.signatures['serving_default'], lower_control_flow=False)
graph_def = frozen_func.graph.as_graph_def(add_shapes=True)
tf.io.write_graph(graph_def, './', 'frozen_model.pb', as_text=False)
with the output of
RuntimeError: Check 'translate_map.count(operation_decoder->get_op_type())' failed at src/frontends/tensorflow/src/frontend.cpp:177:
FrontEnd API failed with OpConversionFailure: :
No translator found for TensorListReserve node.
It seems like the froze models from both codes generate error, and I could not find a ‘standardized’ method to freeze the model as well.
I would deeply appreciate any help as a newbie! Thanks in advance.