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.ops.cs 4.1 kB

4 years ago
4 years ago
6 years ago
6 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. namespace Tensorflow
  16. {
  17. public partial class tensorflow
  18. {
  19. public void add_to_collection<T>(string name, T value)
  20. => get_default_graph().add_to_collection(name, value);
  21. public void add_to_collections<T>(List<string> names, T value)
  22. => get_default_graph().add_to_collections(names, value);
  23. public Tensor assign(IVariableV1 @ref, object value, bool validate_shape = true, bool use_locking = true, string name = null)
  24. => state_ops.assign(@ref, value, validate_shape, use_locking, name);
  25. public void device(string device_name)
  26. => get_default_graph().device(device_name);
  27. public List<T> get_collection<T>(string key, string scope = "")
  28. => get_default_graph().get_collection<T>(key, scope: scope);
  29. /// <summary>
  30. /// A context manager that lifts ops out of control-flow scopes and function-building graphs.
  31. /// When eager execution is enabled, code inside an init_scope block runs with
  32. /// eager execution enabled even when tracing a `tf.function`.
  33. /// </summary>
  34. public void init_scope()
  35. => ops.init_scope();
  36. /// <summary>
  37. /// Returns a context manager that creates hierarchical names for operations.
  38. /// </summary>
  39. /// <param name="name">The name argument that is passed to the op function.</param>
  40. /// <param name="default_name">The default name to use if the name argument is None.</param>
  41. /// <param name="values">The list of Tensor arguments that are passed to the op function.</param>
  42. /// <returns>The scope name.</returns>
  43. public ops.NameScope name_scope(string name, string default_name = "", object values = null)
  44. => new ops.NameScope(name, default_name, values);
  45. /// <summary>
  46. /// Does nothing. Only useful as a placeholder for control edges.
  47. /// </summary>
  48. /// <param name="name"></param>
  49. /// <returns></returns>
  50. public Operation no_op(string name = null)
  51. => gen_control_flow_ops.no_op(name: name);
  52. /// <summary>
  53. /// map on the list of tensors unpacked from `elems` on dimension 0.
  54. /// </summary>
  55. /// <param name="fn"></param>
  56. /// <param name="elems"></param>
  57. /// <param name="dtype"></param>
  58. /// <param name="parallel_iterations"></param>
  59. /// <param name="back_prop"></param>
  60. /// <param name="swap_memory"></param>
  61. /// <param name="infer_shape"></param>
  62. /// <param name="name"></param>
  63. /// <returns>A tensor or (possibly nested) sequence of tensors.</returns>
  64. public Tensor map_fn(Func<Tensor, Tensor> fn,
  65. Tensor elems,
  66. TF_DataType dtype = TF_DataType.DtInvalid,
  67. int parallel_iterations = -1,
  68. bool back_prop = true,
  69. bool swap_memory = false,
  70. bool infer_shape = true,
  71. string name = null)
  72. => Operation.map_fn(fn,
  73. elems,
  74. dtype,
  75. parallel_iterations: parallel_iterations,
  76. back_prop: back_prop,
  77. swap_memory: swap_memory,
  78. infer_shape: infer_shape,
  79. name: name);
  80. }
  81. }