Esempio n. 1
0
        public static Tuple <Matrix <double>, Vector <double> > Coalesce(List <Layer> toCoalesce)
        {
            Debug.Assert(toCoalesce.Count != 0);

            int input_dim  = toCoalesce.First().InputDimension;
            int output_dim = toCoalesce.Last().OutputDimension;

            VCInfo tmp = LPSTerm.GetVariableFactoryState();

            LPSTerm.ResetVariableFactory(input_dim);

            LPSTerm[] identity = LPSTerm.IdentityMatrix(input_dim);
            LPSTerm[] v        = identity;
            for (int i = 0; i < toCoalesce.Count; i++)
            {
                Layer curr = toCoalesce[i];
                var   w    = curr.EvaluateSymbolic(null, v);
                v = w;
            }

            LPSTerm.RestoreVariableFactory(tmp);

            return(new Tuple <Matrix <double>, Vector <double> >(LPSTerm.UnderlyingMatrix(v), LPSTerm.UnderlyingIntercept(v)));
        }
Esempio n. 2
0
 public static void RestoreVariableFactory(VCInfo info)
 {
     vcinfo_ = info;
 }
Esempio n. 3
0
 public static void ResetVariableFactory(int total_variables)
 {
     vcinfo_                 = new VCInfo(total_variables);
     vcinfo_.varcount_       = 0;
     vcinfo_.total_varcount_ = total_variables;
 }