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.math.cs 1.3 kB

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace Tensorflow
  5. {
  6. public static partial class tf
  7. {
  8. public static Tensor add(Tensor a, Tensor b) => gen_math_ops.add(a, b);
  9. public static Tensor sub(Tensor a, Tensor b) => gen_math_ops.sub(a, b);
  10. public static Tensor subtract<T>(Tensor x, T[] y, string name = "") where T : struct
  11. => gen_math_ops.sub(x, ops.convert_to_tensor(y, dtype: x.dtype.as_base_dtype(), name: "y"), name);
  12. public static Tensor multiply(Tensor x, Tensor y) => gen_math_ops.mul(x, y);
  13. public static Tensor divide<T>(Tensor x, T[] y, string name = "") where T : struct
  14. => x / ops.convert_to_tensor(y, dtype: x.dtype.as_base_dtype(), name: "y");
  15. public static Tensor pow<T1, T2>(T1 x, T2 y) => gen_math_ops.pow(x, y);
  16. /// <summary>
  17. /// Computes the sum of elements across dimensions of a tensor.
  18. /// </summary>
  19. /// <param name="input"></param>
  20. /// <param name="axis"></param>
  21. /// <returns></returns>
  22. public static Tensor reduce_sum(Tensor input, int[] axis = null) => math_ops.reduce_sum(input);
  23. public static Tensor cast(Tensor x, TF_DataType dtype = TF_DataType.DtInvalid, string name = "")
  24. => math_ops.cast(x, dtype, name);
  25. }
  26. }

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