mdabros / SharpLearning

Machine learning for C# .Net
MIT License
383 stars 84 forks source link

Issue with loading model using GenericXmlDataContractSerializer: The deserializer has no knowledge of any type that maps to this name #129

Closed xl233 closed 4 years ago

xl233 commented 4 years ago

Thank you so much for developing this package. It's been working smoothly on my computer, but I might need some help on generating a dll file for others to run on their computers. I tried using this nuget package https://github.com/Fody/Costura/graphs/contributors to compile sharplearning dlls into the project dll and adding all sharplearning xml files to embedded resources. But I keep getting the same error saying that "Element 'http://schemas.microsoft.com/2003/10/Serialization/:anyType' contains data from a type that maps to the name 'SharpLearning.GradientBoost.Models:RegressionGradientBoostModel'. The deserializer has no knowledge of any type that maps to this name. " I was wondering where the deserializer knowledge is stored and how do I add them to the project dll file. Any comment or suggestion is appreciated. Thank you!

mdabros commented 4 years ago

Hi @xl233,

Thanks for using SharpLearning, I am glad you find it useful. I am not familiar with the Fody/Costura tool. Can you elaborate a bit on what you are trying to achieve?

Is the problem related to loading a RegressionGradientBoostModel using the GenericXmlDataContractSerializer?

If that is the case, you might have to add the RegressionGradientBoostModel as a known type:

var knownTypes = new[]
{
    typeof(RegressionGradientBoostModel),
};
var serializer = new GenericXmlDataContractSerializer(knownTypes);

best regards Mads

xl233 commented 4 years ago

Thank you so much!!! This immediately solved my problem. Really appreciate it!

xl233 commented 4 years ago

How would you like us to cite you? Thank you!

mdabros commented 4 years ago

@xl233 No need to cite me as such, just make sure that the information from the license is included somehow.

Best of luck with your software!