-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.NET Support #960
Comments
Yes Steven, we hear you and we are sorry for the delay. thx |
That's fantastic, and thank you for the quick reply. I'm happy to wait, I just wanted some signal that it was still in progress. |
Great news! I'm very excited for this. On Oct 27, 2016 9:35 AM, "Steven Gann" notifications@github.com wrote:
|
+1 on C/C++ and C# |
Will support target .NET, .NET Core, or Mono? I am eager to do cross-platform learning in C#. |
python/R is great for research and prototyping - the general "lab settings". this is what alphabet is doing. CNTK extends further as platform and has to support the footprint of why it is being chosen in the first place. small to medium scale commercial projects would benefit from the complete integrated API. For many, C# replaces VB and likes. this is different ML/AI sector - from phone apps to websites and small corporate projects. C# leverages over 15 years of the entire DCOM/J++/COM+/DNA2000 etc effort around integrated windows platform development and is used from distributed applications development, transaction processing to desktop and phone applications. |
@zergxyz I'd like to see some numbers showing that more commercial production code uses R than .NET. I'd like to see some data showing more end-user applications and games using Python than .NET. Can R even be compiled? I know it's basically an open source Matlab but to my knowledge it's still a scripting language. Python can technically be compiled, but compatibility and platform support is poor. Heaven help you if you need something more exotic than the stock Python 2.7 environment. Academics may favor scripting languages like R and Python, but actual applications tend to be written in actual programming languages. Furthermore, the indie game community is largely dominated by C#, at least more so than Python or R, which means
Am I addressing the Godking of Deep Learning? Is there an Asimov-style governing body determining what research can be done and how? You have Python support. I'm sorry if you think R support is more important than C# but the numbers don't lie. C# is more popular than R by every metric. Besides, a quick Google search suggests R already has it's own RNN system, plus it already has support from Tensorflow. Go try Tensorflow instead. |
As these products become more mature they will have to use common languages/platforms , im sick of converting flakey lab code to something that customers can actually use. Large c# programs are everywhere outside of linux (which is used by only a small amount of desktop users). |
We have started actual work on C# bindings.
|
The best would be to clean-up and merge what had been developed for BrainScript with one of the OS libraries or branch it into separate .net development. Math.NET Numerics : http://numerics.mathdotnet.com/ (http://www.mathdotnet.com/) could be a good starting point. It also supports using native library ie. MKL etc. There had been some effort within MSFT to use/expose it as well https://msdn.microsoft.com/en-us/library/hh304363(v=vs.100).aspx There are some smaller tensor library specific porting projects like https://libraries.io/github/alex-weaver/TensorSharp . Not sure I understand your second question. .NET is a framework and leaves the choice of language free. What is the CNTK strategy over the long term ? Is to provide a class library targeting all CLI compliant languages? If yes, then you need to choose the actual framework - for instance .NET CORE which is cross-platform and open source. The language is then only relevant for documentation and QA. Alternatives:
This is TensorFlow discussion about C# API - who face similar strategy choice: |
Thanks for the pointer to the TF issue and the pointers to the libraries. User convenience is the main reason we are doing the bindings. The library is in C++ so if you are determined enough you can program like this, and call it from C# with unsafe code. But that would be ugly, error prone, and hardly deserving to be called "support for .net". |
You are facing some strategic choices for the platform you are building. A lot of CNTK code is redundant or/and dependent on some specific non-easily portable (platform/language) libraries. Looks like you want to re-package the added value over a couple of different directions. If you target the .net framework (for example .NET CORE) you will have python support free with it on par with other CLI languages (https://github.com/IronLanguages). Not targeting .net means exactly what you had said - poor penetration of potential CNTK users who face hurdles of complexity of interfacing with unmanaged code from their .net environment. My point of view is product/platform and the necessary resources. It is clear that anything is feasible and usable right now with a given effort. The core of the platform works well - distributed training using GPU/CPU etc. I would of thought that for model training BrainScript should be enough (with parallel bindings in python). For training via .net applications you could integrate BrainScript into .net or provide a .net library that interprets BrainScript files. You dont have to re-invenent the function by function brainscript binding for model training! The key area is for the model evaluation. Python users would not notice any difference, while people targeting commercial applications (providing a trained model and an application built on top of the model) would benefit from robust model loading and evaluation via managed code support. There is also less of a performance impact - and smaller percentage of use cases requiring HPC like latencies in evaluation. I will have a lot more feedback over the next few weeks as we check various CNTK areas - including real-time usage of CNTK Evaluation (C unmanaged code interfacing with native win C++ DLL that uses CNTK Evaluation) |
@n17s I would wrap the C++ tensor. C# has unsafe pointers for exactly this reason and you don't want large amounts of memory in C# when the lib doing the work is C++ , you especially dont want to move the memory from to C# and then copy it into C++ thats a killer often seen in network stacks. So id provide access to the C++ tensor , pin it to modify . A lot of C# network apis do that as well they hold the packet in native and allow the reading into C# only when desired. Probably consider to just write the wrapper in C++CLI as it fits better with the project however C++ CLI will not fit with core ( and core on Linux) . Agree on brain script only for training , it makes C# a much lighter easier to keep up to date wrapper. Agree on good support here to load and save brain script files. Some methods to construct a brain script file , maybe via expression tree. ( though an extern c call in brainscript would be nice) . |
Sure, the C++ stuff will be wrapped but I believe that's not sufficient. To make this discussion more concrete let's look at this wiki page. An image is loaded, transposed (width x height x channels to channels x height x width), and 128 is subtracted all in one line. This has nothing to do with the CNTK TensorView class, this is all preprocessing to put the input into the right format and numpy is super helpful here. If there's a good library like this in C# we should be leveraging it. |
If this is the immediate orientation... whats wrong with using R.NET? https://rdotnet.codeplex.com/ or looking at the msft R roadmap to see if it fits? |
@avader906 To me, the problem with using R is that if I'm going to use an interpreted scripting language inside my native application, I might as well use Python since it's a lot more developed and supported than R. |
@n17s Its data in C# and there are a number of image processing libraries , ImageProcessor nuget may do - I dont think this should be part of CNTK project at best a community extension to existing image processing . That said my personal project is for the network to do this . |
Um, I'm only asking since it's been a while - rather than a date, could you confirm if .NET support is indeed planned? |
Any news or updates on this one? I saw a new release was out, but nothing noted regarding .NET/C# support. |
2017 now... no love for .net yet? :( |
We have just released the beta version of CNTK Library .NET/C# Eval API. https://github.com/Microsoft/CNTK/releases/tag/v2.0.beta8.0. |
Thanks for this important update @zhouwangzw, we are looking forward to see .NET/C# as a first class citizen with both eval and training API's. |
Definitely a good start. |
What is the current status of the .NET interface support? Is it live now..? Thanks |
There is no API to create networks/train - not that I am aware. They have a beta version of the C# evaluated after you've already trained your network. Personally I have given up hope for .NET support and have been doing all my ML development with TF & Python. The only selling point for me with CNTK was the fact they were talking about support C#, which I love versus Python. Since that does seem to even be a consideration I have moved on. Hopefully they will reconsider ... one day. |
Thanks for that. I see. Well I guess its worth trying to use a pythonnet interface between python and .net. I bet the performance would be a dog though. |
I have just downloaded the RC 2 from April 21st and made a .net c# project with it. Not much there. Is this conformation that c# will be a red headed step child of Python support? |
@SuperDaveOsbourne There is everything needed in C# API to evaluate models trained in Brainscript or Python. However, training models vs evaluating models requires a different ecosphere of support libraries and infrastructure. The core of CNTK is C++ codebase - it is possible to extend the managed API further. From the number of commits it does not look that wider community is participating much in that direction. One has to accept the fact that the product originated from MSFT research, and without much of an external drive, it would be driven by the commercial priorities of the company funding that research. What might impact those priorities?
You can read between the lines from the recent MSFT announcements regarding the future of SQL Server platform and its satellite products (R Server, PolyBase, PDW/APS) as well as Azure. Python will be brought in on par with R and ML libraries will be broaden. Under that view, Python related commits can be interpreted as priority. |
@sethjuarez maybe you can go join this team and give them a leg up!? NuML has some great ideas! |
CNTK 2.2 has a C# API. We welcome feedback and contributions for enhancements. |
<CNTK 2.2 has a C# API. We welcome feedback and contributions for enhancements.> That's one small step for C#, one giant leap for .net mankind. A hello-world example to train and evaluate a logistic regression model using C#/API: https://github.com/Microsoft/CNTK/tree/master/Examples/TrainingCSharp/Common/LogisticRegression.cs |
I have created a slack channel for CNTK for dot net. This is a public link. Workspace URL: cntkdotnet.slack.com |
@SuperDaveOsbourne Why not use the CNTK Gitter channel? |
As Nikos pointed out, we now have a C# API that allows for both training and inference. It covers a reasonably broad set of scenarios (including RNNs and Transfer Learning), but it will require further improvements to reach parity with the Python API at a good performance. Also, we have built this API as a pretty direct mapping to the C++ API using SWIG. This allowed us to move pretty fast, but does not make for a pretty API that follows well established C# design conventions. Our intention here is to build a high-level API on top of this low-level one that would offer easy composition of layers, like the python layers API does. On both aspects (improve the low-level API, design the high-level API) we are looking to the community to participate and help. Please open issues for improvements to the newly published APIs, and, if you see a way for you to fix them, do let us now, so we can coordinate. |
@danielsc The .NET/C# lib draft is indeed a very good news, and it's very cool to see the CNTK team moving in the right direction for the .NET ecosystem. However, at this time, issues like /issues/2374 (a design flaw severely impacting performance) prevents most production uses of the library (except for small datasets). This design problem cannot be fixed by layers on top. |
Could be useful project: https://github.com/deepakkumar1984/SiaNet |
Skip C# and prioritize F#, it can be easily advertised as a better Python. Honestly, what is good about C# for ML? If you want to do ML and .Net, lookout for F#. |
@laygr I think it's a matter of language preference and have nothing to do with ML. I'd easily say "what's good about F#, do C#!" but there's no point in starting a functional vs. imperative holywar. |
@laygr I agree with mikhail-barg. F#, C#, VB all under .NET hood. You can load CNTK in F#. I think the .NET community need to build more libraries similar to python for machine learning. |
@mikhail-barg, @deepakkumar1984. I should have given an example to be more convincing; let's look at the case of Solver Foundation. Microsoft wrote not too long ago a truly great optimization framework called Solver Foundation. It supported .Net, but its design was centered around C# and OOP. However, they also wrote a simple DSL for F# which allowed to define the models in a very succinct way. Lets look at how a model is defined in C# and how it's defined in F# via the DSL. (More on the evident superiority of F# at modeling for Solver Foundation: Units of Measure demo blog post, DSL Demo, check out how constraints are defined. @deepakkumar1984 I agree that we need more libraries to remain competitive against Python. For a quick fix, we can use IronPython, which allows us tu use Python's libraries in .Net. |
@laygr Do you really mean that this Solver Foundation project is dead because MS designed it more for C# not for F#? For me personally it would be a huge downside if CNTK would switch it's focus from C# to F# just because I live more on imperative side of programming universe, and I would have to learn another language just to be able to configure CNTK models (learning another language is not bad by itself, but it looks like an overkill for a modelling task) and it would probably be another DSL built upon F#, right? So why bother, there's already a DSL for these models — BrainScript (and we invested time in learning it already). @deepakkumar1984 I aslo agree on the lack of ML libraries for .Net — I've spent some time just to find that there's no real sound processing library for .Net that is capable to reproduce scipy.signal.spectrogram out of the box. @laygr As far as I know IronPython is rather dead as well. And I'm not sure on the performance side of the C#-IronPyhon-Python-Cython stack (and most of ML Python libraries are built upon native Cython code). |
Referencing here the |
Cross-referecing discussion at #2352 since it's about .NET Standard 2.0. |
I tried going through the C# CTNKLibraryCSharpTrainingExamples today. I think its a great start! I have some feedback, please keep in mind while reading this that it's all from the point-of-view from a complete ML novice who doesn't understand much about what goes on under the hood, only about the general ML workflow of training, validating, and applying a model. Feedback:
Thanks for all your hard work on the C# API! |
Bravely or foolishly taking matters into own hand see issue #2863 (functional nature of F# better suited for math modeling - at the end of the day the DL toolkits are Math languages) |
Some F# and CNTK at http://brandewinder.com/2018/01/14/CNTK-etudes-sequential-model/. |
Another proof-of-concept Keras-like approach - NativeKeras. |
CNTK developers have no belief. |
I'll add here for the benefit of passers-by, the .NET kid on the block seems to MachineLearning.Net. It should be able to use CNTK binaries also. |
多好的 Windows Mobile ,非要东施效颦, |
F# is still .net. if F# support is given and works fully ( e.g. it's not patchy) then it would be possible I have not coded F# for a few years and only tried it for two week, but it certainly did not hurt my coding to read and write a few functions in F#. ( My C# and coding in general actually improved a lot by doing that) So if you are a C# coder don't be afraid to read a few F# function or classes , it will not kill you. You don't even need to learn a new IDE or a new set of libraries . So this is what I am hoping for - that the F# will be supported as well as the Python language is supported. |
C# and CNTK are currently very poorly Wrapped! The CNTK Core I really want to use, but I am not a fan of Python, nor F#, I like the C Style, Java Style. After all, this is the original Programming Language structure, how C++ and C are constructed, like the C++ CNTK Core... So WHY such a terrible job of wrapping the CNTK Core with C#? I am frustrated, C# is an absolutely ideal Graphing Language, CNTK is based of Numerical Graphing, we have an Ideal Match! Sparse Tensors, or Vectors are not working, Value Class or the Binding to the Core is messing with Values. I just think a better job should have been done before releasing this! I am appreciative, don't get me wrong! But what's the point of releasing something when it has so many Buggs! |
C# Programmers unite! Show MSFT we are in need of more! Mean while I have started a website: www.cntking.com for a little push. |
I developed some C# projects for deep learning and they are widely used in different projects and areas. Currently, I mainly focus on this project: https://github.com/zhongkaifu/Seq2SeqSharp It can be used for sequence to sequence task. It's tensor based, supports multi-GPUs, automatic differentiation, built-in Transformer, LSTM network and many other features. You can try it and let me know your feedback if you like. :) |
Issue #817 was closed with this response:
That was September 6th. It's now late October and there's been neither an announcement regarding .NET, nor an update to the original issue.
I'm eager to finally work with deep learning on Windows with C# instead of on Linux with Python. I'm sure Python bindings were helpful to some devs, but frankly every other deep learning framework already supports Python and C++. I'm surprised .NET hasn't been a higher priority, since it's something no other system has been able to provide. Now's the chance to become the de facto deep learning library for OOP development!
The text was updated successfully, but these errors were encountered: