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.

Tensorflow.cs 974 B

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.InteropServices;
  4. using System.Text;
  5. namespace TensorFlowNET.Core
  6. {
  7. public static class Tensorflow
  8. {
  9. public delegate void Deallocator(IntPtr data, IntPtr size, IntPtr deallocatorData);
  10. public static unsafe Tensor constant(object value)
  11. {
  12. var g = ops.get_default_graph();
  13. g.create_op(value, "Const");
  14. return new Tensor();
  15. }
  16. public static Deallocator FreeTensorDataDelegate = FreeTensorData;
  17. [MonoPInvokeCallback(typeof(Deallocator))]
  18. internal static void FreeTensorData(IntPtr data, IntPtr len, IntPtr closure)
  19. {
  20. Marshal.FreeHGlobal(data);
  21. }
  22. public static string VERSION => Marshal.PtrToStringAnsi(c_api.TF_Version());
  23. public static Graph Graph()
  24. {
  25. Graph g = new Graph(c_api.TF_NewGraph());
  26. return g;
  27. }
  28. }
  29. }

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

Contributors (1)