You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 5.6 kB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. # TensorFlow.NET
  2. TensorFlow.NET provides a .NET Standard binding for [TensorFlow](https://www.tensorflow.org/). It aims to implement the complete Tensorflow API in CSharp which allows .NET developers to develop, train and deploy Machine Learning models with the cross-platform .NET Standard framework.
  3. [![Join the chat at https://gitter.im/publiclab/publiclab](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/sci-sharp/community)
  4. [![Tensorflow.NET](https://ci.appveyor.com/api/projects/status/wx4td43v2d3f2xj6?svg=true)](https://ci.appveyor.com/project/Haiping-Chen/tensorflow-net)
  5. [![codecov](https://codecov.io/gh/SciSharp/NumSharp/branch/master/graph/badge.svg)](https://codecov.io/gh/SciSharp/NumSharp)
  6. [![NuGet](https://img.shields.io/nuget/dt/TensorFlow.NET.svg)](https://www.nuget.org/packages/TensorFlow.NET)
  7. [![Documentation Status](https://readthedocs.org/projects/tensorflownet/badge/?version=latest)](https://tensorflownet.readthedocs.io/en/latest/?badge=latest)
  8. [![Badge](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu/#/en_US)
  9. TensorFlow.NET is a member project of [SciSharp STACK](https://github.com/SciSharp).
  10. ![tensors_flowing](docs/assets/tensors_flowing.gif)
  11. ### Why TensorFlow.NET ?
  12. `SciSharp STASK`'s mission is to bring popular data science technology into the .NET world and to provide .NET developers with a powerful Machine Learning tool set without reinventing the wheel. Scince the APIs are kept as similar as possible you can immediately adapt any existing Tensorflow code in C# with a zero learning curve. Take a look at a comparison picture and see how comfortably a Tensorflow/Python script translates into a C# program with TensorFlow.NET.
  13. ![pythn vs csharp](docs/assets/syntax-comparision.png)
  14. SciSharp's philosophy allows a large number of machine learning code written in Python to be quickly migrated to .NET, enabling .NET developers to use cutting edge machine learning models and access a vast number of Tensorflow resources which would not be possible without this project.
  15. In comparison to other projects, like for instance TensorFlowSharp which only provide Tensorflow's low-level C++ API and can only run models that were built using Python, Tensorflow.NET also implements Tensorflow's high level API where all the magic happens. This computation graph building layer is still under active development. Once it is completely implemented you can build new Machine Learning models in C#.
  16. ### How to use
  17. Install TensorFlow.NET through NuGet.
  18. ```sh
  19. PM> Install-Package TensorFlow.NET
  20. ```
  21. If you are using Linux or Mac OS, please download the pre-compiled dll [here](tensorflowlib) and place it in the working folder. This is only need for Linux and Mac OS, and already packed into NuGet for Windows.
  22. Import tensorflow.net.
  23. ```cs
  24. using Tensorflow;
  25. ```
  26. Add two constants.
  27. ```cs
  28. // Create a Constant op
  29. var a = tf.constant(4.0f);
  30. var b = tf.constant(5.0f);
  31. var c = tf.add(a, b);
  32. using (var sess = tf.Session())
  33. {
  34. var o = sess.run(c);
  35. }
  36. ```
  37. Feed placeholder.
  38. ```cs
  39. // Create a placeholder op
  40. var a = tf.placeholder(tf.float32);
  41. var b = tf.placeholder(tf.float32);
  42. var c = tf.add(a, b);
  43. using(var sess = tf.Session())
  44. {
  45. var feed_dict = new Dictionary<Tensor, object>();
  46. feed_dict.Add(a, 3.0f);
  47. feed_dict.Add(b, 2.0f);
  48. var o = sess.run(c, feed_dict);
  49. }
  50. ```
  51. Read the docs & book [The Definitive Guide to Tensorflow.NET](https://tensorflownet.readthedocs.io/en/latest/FrontCover.html).
  52. ### More examples:
  53. * [Hello World](test/TensorFlowNET.Examples/HelloWorld.cs)
  54. * [Basic Operations](test/TensorFlowNET.Examples/BasicOperations.cs)
  55. * [Image Recognition](test/TensorFlowNET.Examples/ImageRecognition.cs)
  56. * [Linear Regression](test/TensorFlowNET.Examples/LinearRegression.cs)
  57. * [Logistic Regression](test/TensorFlowNET.Examples/LogisticRegression.cs)
  58. * [Nearest Neighbor](test/TensorFlowNET.Examples/NearestNeighbor.cs)
  59. * [Text Classification](test/TensorFlowNET.Examples/TextClassificationWithMovieReviews.cs)
  60. * [CNN Text Classification](test/TensorFlowNET.Examples/CnnTextClassification.cs)
  61. * [Naive Bayes Classification](test/TensorFlowNET.Examples/NaiveBayesClassifier.cs)
  62. * [Named Entity Recognition](test/TensorFlowNET.Examples/NamedEntityRecognition.cs)
  63. ### Contribute:
  64. Feel like contributing to one of the hottest projects in the Machine Learning field? Want to know how Tensorflow magically creates the computational graph? We appreciate every contribution however small. There are tasks for novices to experts alike, if everyone tackles only a small task the sum of contributions will be huge.
  65. You can:
  66. * Let everyone know about this project (trivial)
  67. * Port Tensorflow unit tests from Python to C# (easy)
  68. * Port missing Tensorflow code from Python to C# (easy)
  69. * Port Tensorflow examples to C# and raise issues if you come accross missing parts of the API (easy)
  70. * Debug one of the unit tests that is marked as Ignored to get it to work (can be challenging)
  71. * Debug one of the not yet working examples and get it to work (hard)
  72. How to debug unit tests:
  73. The best way to find out why a unit test is failing is to single step it in C# and its pendant Python at the same time to see where the flow of execution digresses or where variables exhibit different values. Good Python IDEs like PyCharm let you single step into the tensorflow library code.
  74. ### Contact
  75. Feel free to star or raise issue on [Github](https://github.com/SciSharp/TensorFlow.NET).
  76. Join our chat on [Gitter](https://gitter.im/sci-sharp/community) or
  77. Scan QR code to join Tencent TIM group:
  78. ![SciSharp STACK](docs/TIM.jpg)

tensorflow框架的.NET版本,提供了丰富的特性和API,可以借此很方便地在.NET平台下搭建深度学习训练与推理流程。