I know there's a rule against self-promotion, but I am hoping my work will actually be very useful for C# and .NET lovers, who also want to get into machine learning.
TL;DR; Over the past 2 years I've made a .NET binding to the full TensorFlow Python API, including Keras, tf.contrib, and, basically, everything else. It's called Gradient, its on NuGet, and you can read the guide here: https://github.com/losttech/Gradient/#getting-started
It started with the desire to explore deep learning, where I quickly discovered you basically have to use Python for the "latest and greatest" frameworks and SotA. And I don't like dynamic languages, and love C#. There was CNTK, which worked nicely, but never gained enough community. It was (and still is) very hard to find advanced sample code for it.
It would take enormous effort to manually port TensorFlow in its entirety to .NET. Projects like TensorFlowSharp and TensorFlow.NET are trying to get to that state, but so far they only provide bindings to the low-level operations and graph construction, while barely touching any high-level features like Keras-like APIs, TensorBoard integration, data pipelines, etc.
So I choose a different approach: automatic source-to-source translation (also because I have quite a bit of experience in this). Originally, the goal was to make a full port, but Python (as any other dynamic languages) is notoriously hard to analyze, and, as it turned out, TensorFlow does not have the cleanest implementation, which made it 5x harder :) About a year ago that forced scope reduction, and currently the project is just making a mostly statically-typed binding for TensorFlow for Python via a great Python embedding library for .NET called Python.NET. To render C# Gradient, of course, uses Roslyn. (BTW, guess which part of Roslyn is the slowest? ... code formatting. Of 30 minutes total build time, about 8 is Python static analysis, and another 12 (!) are spent to convert C# AST into text. Remember that, when you ever feel Visual Studio C# refactoring is slow when it touches many files).
The latest preview (v5) has been out for a bit now, and as the project is closing to RC and official release, I though it is time to share it with a larger community. I am training various models with it right now, including a couple for Kaggle competitions. Even got GPT-2 working and fine-tuning (see samples) - will soon release an open-source song lyrics generator on top of it, so stay tuned ;)
Some links:
Getting Started: https://github.com/losttech/Gradient/#getting-started
Landing page: https://losttech.software/gradient.html
Comments
Post a Comment