I'm trying to load a .pb file that was created in tf v1 on a tfv2 dist, my question is, the version 2 does have compatibility with older pb?
I already tried a few things, but none of them worked. Trying to load the pb file directly with:
with tf.compat.v1.gfile.GFile("./saved_model.pb", "rb") as f:
graph_def = tf.compat.v1.GraphDef()
graph_def.ParseFromString(f.read())
with tf.Graph().as_default() as graph:
tf.import_graph_def(graph_def, name="")
The result when i run the code above is:
Traceback (most recent call last):
File "read_tfv1_pb.py", line 7, in <module>
graph_def.ParseFromString(f.read())
File "D:\Anaconda3\envs\tf2\lib\site-packages\google\protobuf\message.py", line 187, in ParseFromString
return self.MergeFromString(serialized)
File "D:\Anaconda3\envs\tf2\lib\site-packages\google\protobuf\internal\python_message.py", line 1128, in MergeFromString
if self._InternalParse(serialized, 0, length) != length:
File "D:\Anaconda3\envs\tf2\lib\site-packages\google\protobuf\internal\python_message.py", line 1193, in InternalParse
pos = field_decoder(buffer, new_pos, end, self, field_dict)
File "D:\Anaconda3\envs\tf2\lib\site-packages\google\protobuf\internal\decoder.py", line 968, in _SkipFixed32
raise _DecodeError('Truncated message.')
google.protobuf.message.DecodeError: Truncated message.
If not, is there a way that i can save the weights of the old pb and place them in a new model instance on tensorflow v2 to apply transfer learning / save with the new model structure ?