You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that loading the model adds two KeyValuePair to Tensorflow.Train.AutoTrackable. Their keys are non_trainable_variables and layers. Their values are of type Tensorflow.Loader._UserObject.
So saving the model seems to get other KeyValuePair values from TrackableSavedModelSaver.trackable_children(cache) and concatenates them with the KeyValuePair values from Tensorflow.Train.AutoTrackable. This causes a conflict between two values with the same key names (non_trainable_variables and layers) and different values types (Tensorflow.Training.ListWrapper and Tensorflow.Loader._UserObject.)
Converting the concatenated KeyValuePair values to a dictionary will cause the error.
I have just removed the two KeyValuePair values of Tensorflow.Train.AutoTrackable before converting the concatenated KeyValuePair values to dictionary. And it seems to work just fine.
Fix:
In line 30 in the file Tensorflow.Keras/Engine/Layer.Serialize.cs: return children.Concat(base._trackable_children(save_type, cache)).ToDictionary(x => x.Key, x => x.Value);
---> return children.Concat(base._trackable_children(save_type, cache)).GroupBy(x => x.Key).Select(g => g.First()).ToDictionary(x => x.Key, x => x.Value);
Configuration and Other Information
No response
The text was updated successfully, but these errors were encountered:
Description
It seems that loading the model adds two
KeyValuePair
toTensorflow.Train.AutoTrackable
. Their keys arenon_trainable_variables
andlayers
. Their values are of typeTensorflow.Loader._UserObject
.So saving the model seems to get other
KeyValuePair
values fromTrackableSavedModelSaver.trackable_children(cache)
and concatenates them with theKeyValuePair
values fromTensorflow.Train.AutoTrackable
. This causes a conflict between two values with the same key names (non_trainable_variables
andlayers
) and different values types (Tensorflow.Training.ListWrapper
andTensorflow.Loader._UserObject
.)Converting the concatenated
KeyValuePair
values to a dictionary will cause the error.Reproduction Steps
Known Workarounds
I have just removed the two
KeyValuePair
values ofTensorflow.Train.AutoTrackable
before converting the concatenatedKeyValuePair
values to dictionary. And it seems to work just fine.Fix:
In line 30 in the file
Tensorflow.Keras/Engine/Layer.Serialize.cs
:return children.Concat(base._trackable_children(save_type, cache)).ToDictionary(x => x.Key, x => x.Value);
--->
return children.Concat(base._trackable_children(save_type, cache)).GroupBy(x => x.Key).Select(g => g.First()).ToDictionary(x => x.Key, x => x.Value);
Configuration and Other Information
No response
The text was updated successfully, but these errors were encountered: