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.9 kB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*****************************************************************************
  2. Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ******************************************************************************/
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Text;
  16. using Tensorflow.Eager;
  17. using static Tensorflow.ops;
  18. namespace Tensorflow
  19. {
  20. public static partial class tf
  21. {
  22. public static TF_DataType bytes = TF_DataType.TF_STRING;
  23. public static TF_DataType int16 = TF_DataType.TF_INT16;
  24. public static TF_DataType int32 = TF_DataType.TF_INT32;
  25. public static TF_DataType int64 = TF_DataType.TF_INT64;
  26. public static TF_DataType float16 = TF_DataType.TF_HALF;
  27. public static TF_DataType float32 = TF_DataType.TF_FLOAT;
  28. public static TF_DataType float64 = TF_DataType.TF_DOUBLE;
  29. public static TF_DataType @bool = TF_DataType.TF_BOOL;
  30. public static TF_DataType chars = TF_DataType.TF_STRING;
  31. public static Context context = new Context(new ContextOptions(), new Status());
  32. public static Session defaultSession;
  33. public static RefVariable Variable<T>(T data,
  34. bool trainable = true,
  35. bool validate_shape = true,
  36. string name = null,
  37. TF_DataType dtype = TF_DataType.DtInvalid)
  38. {
  39. return Tensorflow.variable_scope.default_variable_creator(data,
  40. trainable: trainable,
  41. validate_shape: validate_shape,
  42. name: name,
  43. dtype: TF_DataType.DtInvalid);
  44. }
  45. public static unsafe Tensor placeholder(TF_DataType dtype, TensorShape shape = null, string name = null)
  46. {
  47. return gen_array_ops.placeholder(dtype, shape, name);
  48. }
  49. public static void enable_eager_execution()
  50. {
  51. // contex = new Context();
  52. context.default_execution_mode = Context.EAGER_MODE;
  53. }
  54. public static string VERSION => c_api.StringPiece(c_api.TF_Version());
  55. public static Session Session()
  56. {
  57. defaultSession = new Session();
  58. return defaultSession;
  59. }
  60. public static Session Session(Graph graph)
  61. {
  62. return new Session(graph);
  63. }
  64. }
  65. }