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.random.cs 3.1 kB

6 years ago
6 years ago
6 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. namespace Tensorflow
  14. {
  15. public partial class tensorflow
  16. {
  17. /// <summary>
  18. /// Outputs random values from a normal distribution.
  19. /// </summary>
  20. /// <param name="shape"></param>
  21. /// <param name="mean"></param>
  22. /// <param name="stddev"></param>
  23. /// <param name="dtype"></param>
  24. /// <param name="seed"></param>
  25. /// <param name="name"></param>
  26. /// <returns></returns>
  27. public Tensor random_normal(TensorShape shape,
  28. float mean = 0.0f,
  29. float stddev = 1.0f,
  30. TF_DataType dtype = TF_DataType.TF_FLOAT,
  31. int? seed = null,
  32. string name = null) => random_ops.random_normal(shape, mean, stddev, dtype, seed, name);
  33. public Tensor random_uniform(TensorShape shape,
  34. float minval = 0,
  35. float maxval = 1,
  36. TF_DataType dtype = TF_DataType.TF_FLOAT,
  37. int? seed = null,
  38. string name = null) => random_ops.random_uniform(shape, minval, maxval, dtype, seed, name);
  39. public Tensor truncated_normal(TensorShape shape,
  40. float mean = 0.0f,
  41. float stddev = 1.0f,
  42. TF_DataType dtype = TF_DataType.TF_FLOAT,
  43. int? seed = null,
  44. string name = null)
  45. => random_ops.truncated_normal(shape, mean, stddev, dtype, seed, name);
  46. /// <summary>
  47. /// Randomly shuffles a tensor along its first dimension.
  48. /// </summary>
  49. /// <param name="value"></param>
  50. /// <param name="seed"></param>
  51. /// <param name="name"></param>
  52. /// <returns>
  53. /// A tensor of same shape and type as value, shuffled along its
  54. /// first dimension.
  55. /// </returns>
  56. public Tensor random_shuffle(Tensor value, int? seed = null, string name = null)
  57. => random_ops.random_shuffle(value, seed: seed, name: name);
  58. public void set_random_seed(int seed)
  59. => ops.get_default_graph().seed = seed;
  60. public Tensor multinomial(Tensor logits, int num_samples, int? seed = null,
  61. string name = null, TF_DataType output_dtype = TF_DataType.DtInvalid)
  62. => random_ops.multinomial(logits, num_samples, seed: seed,
  63. name: name, output_dtype: output_dtype);
  64. }
  65. }