Ejemplo n.º 1
0
 private static IBackend load()
 {
     //Type type = find(typeName);
     // Type type = typeof(UnityTFBackend);
     //IBackend obj = (IBackend)Activator.CreateInstance(type);
     try
     {
         IBackend obj = new UnityTFBackend();
         return(obj);
     }
     catch (Exception e)
     {
         UnityEngine.Debug.LogError("Exception in Current.load():" + e.Message);
     }
     return(null);
 }
Ejemplo n.º 2
0
        public UnityTFFunction(UnityTFBackend k, List <Tensor> inputs, List <Tensor> outputs, List <List <Tensor> > updates, string name)
        {
            this.backend = k;
            this.graph   = k.Graph;

            if (updates == null)
            {
                updates = new List <List <Tensor> >();
            }
            this.inputs  = inputs;
            this.outputs = outputs;
            {
                var updates_ops = new List <TFOperation>();
                foreach (List <Tensor> update in updates)
                {
                    if (update.Count == 2)
                    {
                        var p     = backend.In(update[0]);
                        var new_p = backend.In(update[1]);
                        updates_ops.Add(graph.AssignVariableOp(p, new_p));
                    }
                    else if (update.Count == 1)
                    {
                        // assumed already an op
                        var op = backend.In(update[0]).Output.Operation;
                        Debug.Assert(op != null, "Null op");
                        updates_ops.Add(op);
                    }
                    else
                    {
                        throw new NotSupportedException();
                    }
                }

                //this.updates_op = tf.group(updates_ops);
                this.updates_op = updates_ops;
            }

            this.name = name;
            //this.session_kwargs = session_kwargs;
        }