SciSharp/TensorFlow.NET

[Question]: System.NotImplementedException in Tensorflow.Checkpoint.CheckpointPosition._queue_slot_variables

DenisBauer opened this issue · 0 comments

Description

Apologies if this is a noob question but I am new to the project.

Setup:
I created a TF model in Python using the tf.keras.optimizers.Adam() optimizer and persist it to disk. Then I wrote a C# TensorFlow.NET program that tries to load that model.

Observation:
The call to keras.models.load_model fails with a System.NotImplementedException at the following call stack:

   at Tensorflow.Checkpoint.CheckpointPosition._queue_slot_variables(CheckpointPosition checkpoint_position, Queue`1 visit_queue)
   at Tensorflow.Checkpoint.CheckpointPosition._restore_descendants()
   at Tensorflow.Checkpoint.CheckpointPosition.restore(Trackable trackable)
   at Tensorflow.Checkpoint.TrackableSaver.restore(String save_path, CheckpointOptions options)
   at Tensorflow.Loader._restore_checkpoint()
   at Tensorflow.Loader..ctor(SavedObjectGraph object_graph_proto, SavedModel saved_model_proto, String export_dir, CheckpointOptions ckpt_options, LoadOptions save_options, IDictionary`2 filters)
   at Tensorflow.Loader.<>c__DisplayClass45_1.<load_partial>b__3(NameScope x)
   at Tensorflow.Binding.tf_with[T](T py, Action`1 action)
   at Tensorflow.Loader.load_partial(String export_dir, IDictionary`2 filters, Object tags, LoadOptions options)
   at Tensorflow.Keras.Saving.SavedModel.KerasLoadModelUtils.load(String path, Boolean compile, LoadOptions options)
   at Tensorflow.Keras.Saving.SavedModel.KerasLoadModelUtils.load_model(String filepath, IDictionary`2 custom_objects, Boolean compile, LoadOptions options)
   at Tensorflow.Keras.Models.ModelsApi.load_model(String filepath, Boolean compile, LoadOptions options)

When changing from Adam to SGD optimizer, everything works fine (but performance is bad).

I narrowed the problem down to this line in the source code:

throw new NotImplementedException();

➡️ My question: is this approach a known unsupported issue or am I doing something wrong.

Alternatives

No response