Exemplo n.º 1
0
 protected Variable(Type dataType, VariableType type, Expr initializer)
 {
     DataType     = dataType;
     Type         = type;
     _shape       = initializer != null ? new PartialShape(initializer.Shape.AsArray) : null;
     _initializer = initializer;
     _owner       = null;
 }
Exemplo n.º 2
0
 protected Variable(Type dataType, VariableType type, PartialShape shape)
 {
     DataType     = dataType;
     Type         = type;
     _shape       = shape;
     _initializer = null;
     _owner       = null;
 }
Exemplo n.º 3
0
        private void SetForwardOrder(Differentiable op, HashSet <Differentiable> cache)
        {
            if (cache.Contains(op))
            {
                return;
            }

            foreach (var input in op.Inputs)
            {
                SetForwardOrder(input, cache);
            }

            _forwardOrder.Add(op);
            cache.Add(op);
        }
Exemplo n.º 4
0
        private void AddData(Differentiable op, HashSet <Differentiable> cache)
        {
            if (cache.Contains(op))
            {
                return;
            }

            foreach (var input in op.Inputs)
            {
                AddData(input, cache);
            }

            foreach (var auxVar in op.AuxVars)
            {
                AddData(auxVar, cache);
            }

            foreach (var output in op.Outputs)
            {
                _data.Add(output, new Data(Context, output));
            }

            cache.Add(op);
        }