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.

tf.cs 2.3 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Tensorflow.Eager;
  5. using static Tensorflow.ops;
  6. namespace Tensorflow
  7. {
  8. public static partial class tf
  9. {
  10. public static TF_DataType bytes = TF_DataType.TF_STRING;
  11. public static TF_DataType int16 = TF_DataType.TF_INT16;
  12. public static TF_DataType int32 = TF_DataType.TF_INT32;
  13. public static TF_DataType int64 = TF_DataType.TF_INT64;
  14. public static TF_DataType float16 = TF_DataType.TF_HALF;
  15. public static TF_DataType float32 = TF_DataType.TF_FLOAT;
  16. public static TF_DataType float64 = TF_DataType.TF_DOUBLE;
  17. public static TF_DataType boolean = TF_DataType.TF_BOOL;
  18. public static TF_DataType chars = TF_DataType.TF_STRING;
  19. public static Context context = new Context(new ContextOptions(), new Status());
  20. public static Session defaultSession;
  21. public static RefVariable Variable<T>(T data,
  22. bool trainable = true,
  23. bool validate_shape = true,
  24. string name = null,
  25. TF_DataType dtype = TF_DataType.DtInvalid)
  26. {
  27. return Tensorflow.variable_scope.default_variable_creator(data,
  28. trainable: trainable,
  29. validate_shape: validate_shape,
  30. name: name,
  31. dtype: TF_DataType.DtInvalid);
  32. }
  33. public static unsafe Tensor placeholder(TF_DataType dtype, TensorShape shape = null, string name = null)
  34. {
  35. return gen_array_ops.placeholder(dtype, shape, name);
  36. }
  37. public static void enable_eager_execution()
  38. {
  39. // contex = new Context();
  40. context.default_execution_mode = Context.EAGER_MODE;
  41. }
  42. public static string VERSION => c_api.StringPiece(c_api.TF_Version());
  43. public static Graph get_default_graph()
  44. {
  45. return ops.get_default_graph();
  46. }
  47. public static Graph Graph() => new Graph();
  48. public static Session Session()
  49. {
  50. defaultSession = new Session();
  51. return defaultSession;
  52. }
  53. public static Session Session(Graph graph)
  54. {
  55. return new Session(graph);
  56. }
  57. }
  58. }