예제 #1
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((Rho.GetHashCode() * 397) ^ Theta.GetHashCode());
     }
 }
예제 #2
0
파일: Model.cs 프로젝트: vcfriend/svmnet
        public override bool Equals(object obj)
        {
            Model test = obj as Model;

            if (test == null)
            {
                return(false);
            }

            bool same = ClassLabels.IsEqual(test.ClassLabels);

            same = same && NumberOfClasses == test.NumberOfClasses;
            same = same && NumberOfSVPerClass.IsEqual(test.NumberOfSVPerClass);
            if (PairwiseProbabilityA != null)
            {
                same = same && PairwiseProbabilityA.IsEqual(test.PairwiseProbabilityA);
            }
            if (PairwiseProbabilityB != null)
            {
                same = same && PairwiseProbabilityB.IsEqual(test.PairwiseProbabilityB);
            }
            same = same && Parameter.Equals(test.Parameter);
            same = same && Rho.IsEqual(test.Rho);
            same = same && SupportVectorCoefficients.IsEqual(test.SupportVectorCoefficients);
            same = same && SupportVectorCount == test.SupportVectorCount;
            same = same && SupportVectors.IsEqual(test.SupportVectors);
            return(same);
        }
예제 #3
0
        public override void Optimize()
        {
            GradientClipper.Clip(this);

            foreach (var data in Data)
            {
                if (data.Variable.Type == VariableType.Parameter)
                {
                    if (data.Variable.DataType == typeof(float))
                    {
                        var a = _weights[data.Variable].Cast <float>();
                        var p = data.Tensor.Cast <float>();
                        var g = data.Gradient.Cast <float>();
                        Context.Assign(a, Rho.AsScalar <float>() * a + (1.0.AsScalar <float>() - Rho.AsScalar <float>()) * g * g);
                        Context.Assign(p, p - LearningRate.AsScalar <float>() * g / (Sqrt(a) + Epsilon.AsScalar <float>()));
                    }
                    else if (data.Variable.DataType == typeof(double))
                    {
                        var a = _weights[data.Variable].Cast <double>();
                        var p = data.Tensor.Cast <double>();
                        var g = data.Gradient.Cast <double>();
                        Context.Assign(a, Rho.AsScalar <double>() * a + (1.0.AsScalar <double>() - Rho.AsScalar <double>()) * g * g);
                        Context.Assign(p, p - LearningRate.AsScalar <double>() * g / (Sqrt(a) + Epsilon.AsScalar <double>()));
                    }
                    else
                    {
                        throw new InvalidOperationException();
                    }
                }
            }
        }
        override public void initialize()
        {
            setProblemClass();

            int total_nodes = this.Ranks.Length;

            maxcells = Convert.ToInt32(Math.Sqrt(total_nodes));
            ncells   = Convert.ToInt32(Math.Sqrt(total_nodes));

            MAX_CELL_DIM     = (problem_size / maxcells) + 1;
            IMAX             = JMAX = KMAX = MAX_CELL_DIM;
            _grid_points_[0] = _grid_points_[1] = _grid_points_[2] = problem_size;
            IMAXP            = IMAX / 2 * 2 + 1;
            JMAXP            = JMAX / 2 * 2 + 1;

            set_constants(0, dt_default);

            U.initialize_field("u", maxcells, KMAX + 4, JMAXP + 4, IMAXP + 4, 5);
            Rhs.initialize_field("rhs", maxcells, KMAX + 2, JMAXP + 2, IMAXP + 2, 5);
            Lhs.initialize_field("lhs", maxcells, KMAX + 2, JMAXP + 2, IMAXP + 2, 15);
            Forcing.initialize_field("forcing", maxcells, KMAX + 2, JMAXP + 2, IMAXP + 2, 5);

            Us.initialize_field("us", maxcells, KMAX + 3, JMAX + 3, IMAX + 3);
            Vs.initialize_field("vs", maxcells, KMAX + 3, JMAX + 3, IMAX + 3);
            Ws.initialize_field("ws", maxcells, KMAX + 3, JMAX + 3, IMAX + 3);
            Qs.initialize_field("qs", maxcells, KMAX + 3, JMAX + 3, IMAX + 3);
            Ainv.initialize_field("ainv", maxcells, KMAX + 3, JMAX + 3, IMAX + 3);
            Rho.initialize_field("rho", maxcells, KMAX + 3, JMAX + 3, IMAX + 3);
            Speed.initialize_field("speed", maxcells, KMAX + 3, JMAX + 3, IMAX + 3);
            Square.initialize_field("square", maxcells, KMAX + 3, JMAX + 3, IMAX + 3);

            //Lhsa.initialize_field("lhsa", maxcells, KMAX+2, JMAXP+2, IMAXP+2, 15);
            //Lhsb.initialize_field("lhsb", maxcells, KMAX+2, JMAXP+2, IMAXP+2, 15);
            //Lhsc.initialize_field("lhsc", maxcells, KMAX+2, JMAXP+2, IMAXP+2, 15);
        }
예제 #5
0
 protected override void EncodeParameterCore(ref string res)
 {
     res += OutScale.ToString() + " ";
     res += KernelSize.ToString() + " ";
     res += KernelExpand.ToString() + " ";
     res += OptimizerType.ToString() + " ";
     res += Rho.ToString() + " ";
 }
예제 #6
0
 protected bool Equals(Greeks other)
 {
     return(Gamma.AlmostEqual(other.Gamma, 4) &&
            Delta.AlmostEqual(other.Delta, 4) &&
            Theta.AlmostEqual(other.Theta, 4) &&
            Vega.AlmostEqual(other.Vega, 4) &&
            Rho.AlmostEqual(other.Rho, 4) &&
            RhoFx.AlmostEqual(other.RhoFx, 4) &&
            Sigma.AlmostEqual(other.Sigma, 4));
 }
예제 #7
0
        public SVMModel Clone()
        {
            SVMModel y = new SVMModel();

            if (Parameter != null)
            {
                y.Parameter = Parameter.Clone();
            }

            y.ClassCount   = ClassCount;
            y.TotalSVCount = TotalSVCount;

            if (SV != null)
            {
                y.SV = SV.Select(a => a.Select(b => b.Clone()).ToArray()).ToList();
            }

            if (SVCoefs != null)
            {
                y.SVCoefs = SVCoefs.Select(a => a.Select(b => b).ToArray()).ToList();
            }

            if (Rho != null)
            {
                y.Rho = Rho.Select(a => a).ToArray();
            }

            if (ProbabilityA != null)
            {
                y.ProbabilityA = ProbabilityA.Select(a => a).ToArray();
            }

            if (ProbabilityB != null)
            {
                y.ProbabilityB = ProbabilityB.Select(a => a).ToArray();
            }

            if (SVIndices != null)
            {
                y.SVIndices = SVIndices.Select(a => a).ToArray();
            }

            if (Labels != null)
            {
                y.Labels = Labels.Select(a => a).ToArray();
            }

            if (SVCounts != null)
            {
                y.SVCounts = SVCounts.Select(a => a).ToArray();
            }

            y.Creation = Creation;
            return(y);
        }
예제 #8
0
파일: Model.cs 프로젝트: vcfriend/svmnet
 public override int GetHashCode()
 {
     return(ClassLabels.ComputeHashcode() +
            NumberOfClasses.GetHashCode() +
            NumberOfSVPerClass.ComputeHashcode() +
            PairwiseProbabilityA.ComputeHashcode() +
            PairwiseProbabilityB.ComputeHashcode() +
            Parameter.GetHashCode() +
            Rho.ComputeHashcode() +
            SupportVectorCoefficients.ComputeHashcode() +
            SupportVectorCount.GetHashCode() +
            SupportVectors.ComputeHashcode());
 }
예제 #9
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = Gamma.GetHashCode();
         hashCode = (hashCode * 397) ^ Delta.GetHashCode();
         hashCode = (hashCode * 397) ^ Theta.GetHashCode();
         hashCode = (hashCode * 397) ^ Vega.GetHashCode();
         hashCode = (hashCode * 397) ^ Rho.GetHashCode();
         hashCode = (hashCode * 397) ^ RhoFx.GetHashCode();
         hashCode = (hashCode * 397) ^ Sigma.GetHashCode();
         return(hashCode);
     }
 }
예제 #10
0
        public override string ToString()
        {
            string returnString = "";

            returnString += "T: " + EnginesGUI.GUIUnitsSettings.TemperatureUnits.Format(T);
            returnString += " P: " + EnginesGUI.GUIUnitsSettings.PressureUnits.Format(P);
            returnString += " Rho: " + Rho.ToString("F2");
            returnString += "\n FF: " + FF.ToString("F3");
            returnString += "\n Cp: " + Cp.ToString("F2");
            returnString += " Cv: " + Cv.ToString("F2");
            returnString += "\nGamma: " + Gamma.ToString("F2");
            returnString += " R: " + R.ToString("F2");
            return(returnString);
        }
예제 #11
0
        private Dictionary <char, string> MakeDictionary()
        {
            var dict = new Dictionary <char, string>();

            dict['s'] = "Sample " + Samples;
            dict['f'] = "Feature " + Dimension;
            dict['n'] = "Nu " + Nu;
            dict['t'] = "Time " + ExecutionTime;
            dict['i'] = "Iteration " + Iteration;
            dict['v'] = "#SupportVector " + CountSupportVectors;
            dict['w'] = MakeStringW();
            dict['b'] = "B " + B.ToString();
            dict['r'] = "Rho " + Rho.ToString();
            dict['c'] = "C " + C.ToString();
            dict['o'] = "OptimalValue " + OptValue;
            dict['a'] = "Accuracy " + Accuracy;
            dict['l'] = MakeLable();
            return(dict);
        }
예제 #12
0
 protected bool Equals(PolarPointF other)
 {
     return(Rho.Equals(other.Rho) && Theta.Equals(other.Theta));
 }
예제 #13
0
 protected override void EncodeParameterCore(ref string res)
 {
     res += OptimizerType.ToString() + " ";
     res += Rho.ToString() + " ";
 }
예제 #14
0
 public static ValPosPlr ValPosPlr(Theta t, Rho r, double value = 0)
 => new ValPosPlr(t, r, value);