TensorFlow.NET
TensorFlow.NET copied to clipboard
[Question]: Error when using keras.models.load_model()
Description
i am geting this error when trying to load the model :
Tensorflow.ValueError: 'The tensor conv1d/Relu:0 at layer l_s_t_m is part of a cycle.'
the model :
public static IModel MultivariateImprovedRNNModel(List
var inputs = keras.Input(shape: new Shape(inputShape[1], inputShape[0]));
model.add(inputs);
model.add(layer.Conv1D(256, kernel_size: 1, padding: "same", activation: "relu", strides: 1));
model.add(layer.LSTM(256, return_sequences: true));
model.add(layer.LSTM(256));
model.add(layer.Dense(6));
model.summary();
model.compile(optimizer: keras.optimizers.Adam(learning_rate: 0.001f),
loss: keras.losses.MeanSquaredError(),
metrics: new[] { "mean_absolute_error" });
return model;
}
Alternatives
No response
I can't call this method at all. I created a very basic model with the layers api, saved it, then tried to load it next iteration and I'm getting this error:
System.ArgumentNullException: Value cannot be null.
at System.ArgumentNullException.Throw(String paramName)
at System.Reflection.RuntimeMethodInfo.MakeGenericMethod(Type[] methodInstantiation)
at Tensorflow.Keras.Utils.generic_utils.deserialize_layer_args(String class_name, JToken config)
at Tensorflow.Keras.Utils.generic_utils.deserialize_model_config(JToken json)
at Tensorflow.Keras.Saving.KerasObjectLoader._reconstruct_model(Int32 model_id, Model model, List`1 layers)
at Tensorflow.Keras.Saving.KerasObjectLoader._reconstruct_all_models()
at Tensorflow.Keras.Saving.KerasObjectLoader.finalize_objects()
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)
I'm very sorry, because the developer responsible for this api is busy recently, so it may not be so fast to solve this problem, I will let you know once it is completed.
I can't call this method at all. I created a very basic model with the layers api, saved it, then tried to load it next iteration and I'm getting this error:
System.ArgumentNullException: Value cannot be null. at System.ArgumentNullException.Throw(String paramName) at System.Reflection.RuntimeMethodInfo.MakeGenericMethod(Type[] methodInstantiation) at Tensorflow.Keras.Utils.generic_utils.deserialize_layer_args(String class_name, JToken config) at Tensorflow.Keras.Utils.generic_utils.deserialize_model_config(JToken json) at Tensorflow.Keras.Saving.KerasObjectLoader._reconstruct_model(Int32 model_id, Model model, List`1 layers) at Tensorflow.Keras.Saving.KerasObjectLoader._reconstruct_all_models() at Tensorflow.Keras.Saving.KerasObjectLoader.finalize_objects() 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)
Hello, I have located the error, could you mind provide a simple code to show your model? I will test my idea. Thank you very much.
Hello, dose this bug still exist? If so, could you please provide a minimul example for reproduction?