using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Tensorflow { public class variables { /// /// Returns all variables created with `trainable=True` /// /// public static object trainable_variables() { return ops.get_collection(ops.GraphKeys.TRAINABLE_VARIABLES); } /// /// Returns all variables and `SaveableObject`s that must be checkpointed. /// /// /// public static RefVariable[] _all_saveable_objects(string scope = "") { var all = new List(); var collection = ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES, scope); if(collection != null) all.AddRange(collection as List); collection = ops.get_collection(ops.GraphKeys.SAVEABLE_OBJECTS, scope); if (collection != null) all.AddRange(collection as List); return all.ToArray(); } /// /// Returns global variables. /// /// /// (Optional.) A string. If supplied, the resulting list is filtered /// to include only items whose `name` attribute matches `scope` using /// `re.match`. Items without a `name` attribute are never returned if a /// scope is supplied. The choice of `re.match` means that a `scope` without /// special tokens filters by prefix. /// /// A list of `Variable` objects. public static List global_variables(string scope = "") { var result = ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES, scope); return result as List; } /// /// Returns an Op that initializes a list of variables. /// /// List of `Variable` objects to initialize. /// Optional name for the returned operation. /// An Op that run the initializers of all the specified variables. public static Operation variables_initializer(RefVariable[] var_list, string name = "init") { return control_flow_ops.group(var_list.Select(x => x.initializer).ToArray(), name); } } }