Reputation: 799
My biggest problem is that at this point many things related to binding TorchSharp and ML.NET are not completed, even though in many sources I saw that the work is in progress, but I hope to be able to overcome it somehow. The main requirement is to use only C#.NET for training a very custom neural network model from the scratch and then for running it. Please don't make emphasis on this requirement. It is what it is. The question is how to train a model and then run it?
So far, I managed to train a model using TorchSharp and save it with a hope to use it later in ML.NET but it looks like TorchSharp saves the model in a format very specific to torch/PyTorch/TorchSharp. It looks like PyTorch has torch.onnx.export method but TorchSharp doesn't have such method. So, I'm stuck at a point how to save my trained model as ONNX?
Then I hope to be able to load/import that ONNX to ML.NET using OnnxTransformer and run it. Any suggestions, keeping in mind that everything needs to be in C#.NET? There is one other thing to add. I guess I can load and run the model using TorchSharp itself but there is already written code using ML.NET for running other models so I hoped to have a unified interface for running via ML.NET.
Upvotes: 1
Views: 1822
Reputation: 11
The ML.NET team initiated surveys last 2 years and it was clear there is a strong demand for integrating deep learning.
It seems from the roadmap, there are TWO pronged approaches.
If your interest is deep learning in .NET, Torchsharp is the best .NET option right now. In 6-9 months, the integration of TorchSharp within ML.NET will become more mature.
Consider experimenting with TorchSharp or integration with it in ML.NET through dotnet's PolyGlot notebook. It seems the dotnet's team is experimenting with new features e.g. adding more languages.
Upvotes: 1
Reputation: 649
Being able to run models trained with TorchSharp in ML.NET is part of our roadmap. However, it's not something we'll be delivering in the near future (next 6-9 months).
I think in the short-term the best path forward is what you suggested:
run the model using TorchSharp itself
Upvotes: 3