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.array.cs 1.7 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace Tensorflow
  5. {
  6. public static partial class tf
  7. {
  8. /// <summary>
  9. /// Inserts a dimension of 1 into a tensor's shape.
  10. /// </summary>
  11. /// <param name="input"></param>
  12. /// <param name="axis"></param>
  13. /// <param name="name"></param>
  14. /// <param name="dim"></param>
  15. /// <returns>
  16. /// A `Tensor` with the same data as `input`, but its shape has an additional
  17. /// dimension of size 1 added.
  18. /// </returns>
  19. public static Tensor expand_dims(Tensor input, int axis = -1, string name = null, int dim = -1)
  20. => array_ops.expand_dims(input, axis, name, dim);
  21. /// <summary>
  22. /// Transposes `a`. Permutes the dimensions according to `perm`.
  23. /// </summary>
  24. /// <param name="a"></param>
  25. /// <param name="perm"></param>
  26. /// <param name="name"></param>
  27. /// <param name="conjugate"></param>
  28. /// <returns></returns>
  29. public static Tensor transpose<T1, T2>(T1 a, T2 perm, string name = "transpose", bool conjugate = false)
  30. => array_ops.transpose(a, perm, name, conjugate);
  31. public static Tensor squeeze(Tensor input, int[] axis = null, string name = null, int squeeze_dims = -1)
  32. => gen_array_ops.squeeze(input, axis, name);
  33. public static Tensor one_hot(Tensor indices, int depth,
  34. Tensor on_value = null,
  35. Tensor off_value = null,
  36. TF_DataType dtype = TF_DataType.DtInvalid,
  37. int axis = -1,
  38. string name = null) => array_ops.one_hot(indices, depth, dtype: dtype, axis: axis, name: name);
  39. }
  40. }

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