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 3.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. /// Return the elements, either from `x` or `y`, depending on the `condition`.
  23. /// </summary>
  24. /// <returns></returns>
  25. public static Tensor where<Tx, Ty>(Tensor condition, Tx x, Ty y, string name = null)
  26. => array_ops.where(condition, x, y, name);
  27. /// <summary>
  28. /// Transposes `a`. Permutes the dimensions according to `perm`.
  29. /// </summary>
  30. /// <param name="a"></param>
  31. /// <param name="perm"></param>
  32. /// <param name="name"></param>
  33. /// <param name="conjugate"></param>
  34. /// <returns></returns>
  35. public static Tensor transpose<T1>(T1 a, int[] perm = null, string name = "transpose", bool conjugate = false)
  36. => array_ops.transpose(a, perm, name, conjugate);
  37. public static Tensor squeeze(Tensor input, int[] axis = null, string name = null, int squeeze_dims = -1)
  38. => gen_array_ops.squeeze(input, axis, name);
  39. /// <summary>
  40. /// Stacks a list of rank-`R` tensors into one rank-`(R+1)` tensor.
  41. /// </summary>
  42. /// <param name="values"></param>
  43. /// <param name="axis"></param>
  44. /// <param name="name"></param>
  45. /// <returns></returns>
  46. public static Tensor stack(object values, int axis = 0, string name = "stack")
  47. => array_ops.stack(values, axis, name: name);
  48. public static Tensor one_hot(Tensor indices, int depth,
  49. Tensor on_value = null,
  50. Tensor off_value = null,
  51. TF_DataType dtype = TF_DataType.DtInvalid,
  52. int axis = -1,
  53. string name = null) => array_ops.one_hot(indices, depth, dtype: dtype, axis: axis, name: name);
  54. /// <summary>
  55. /// A placeholder op that passes through `input` when its output is not fed.
  56. /// </summary>
  57. /// <typeparam name="T"></typeparam>
  58. /// <param name="input">A `Tensor`. The default value to produce when output is not fed.</param>
  59. /// <param name="shape">
  60. /// A `tf.TensorShape` or list of `int`s. The (possibly partial) shape of
  61. /// the tensor.
  62. /// </param>
  63. /// <param name="name">A name for the operation (optional).</param>
  64. /// <returns>A `Tensor`. Has the same type as `input`.</returns>
  65. public static Tensor placeholder_with_default<T>(T input, int[] shape, string name = null)
  66. => gen_array_ops.placeholder_with_default(input, shape, name: name);
  67. }
  68. }