private void DualPerceptron(List <Tuple <double[], double> > data) { Kernel kernel = new LinearKernel(); foreach (var item in netMLObject.Options) { if (item == "linearkernel") { kernel = new LinearKernel(); } else if (item == "gaussiankernel") { kernel = new GaussianKernel(1.0); } else if (item == "polynomialkernel") { kernel = new PolynomialKernel(1); } else if (item == "logitkernel") { kernel = new LogitKernel(); } else if (item == "tanhkernel") { kernel = new TanhKernel(); } } classification = new DualPerceptronClassifier(data, kernel); }
public void TanhPrimeTest() { var a = new Matrix(2, 2); a.InRandomize(); var b = a.Duplicate(); a = new TanhKernel().Backward(a); b.InMap((x) => 1 - Math.Pow((Math.Exp(x) - Math.Exp(-x)) / (Math.Exp(x) + Math.Exp(-x)), 2)); Assert.IsTrue(a == b, "Tanh Derivative successful"); }
public void TanhTest() { var a = new Matrix(2, 2); a.InRandomize(); var b = a.Duplicate(); a = new TanhKernel().Forward(a); b.InMap((x) => (Math.Exp(x) - Math.Exp(-x)) / (Math.Exp(x) + Math.Exp(-x))); Assert.IsTrue(a == b, "Tanh Activation successful"); }
private void SupportVectorMachine(List <Tuple <double[], double> > data) { Kernel kernel = new LinearKernel(); double n = 0.0; double C = 0.0; bool nAndCSet = false; foreach (var item in netMLObject.Options) { if (item == "linearkernel") { kernel = new LinearKernel(); } else if (item == "gaussiankernel") { kernel = new GaussianKernel(1.0); } else if (item == "polynomialkernel") { kernel = new PolynomialKernel(1); } else if (item == "logitkernel") { kernel = new LogitKernel(); } else if (item == "tanhkernel") { kernel = new TanhKernel(); } } foreach (var value in netMLObject.DoubleValues) { if (value.Key == "n") { n = value.Value; nAndCSet = true; } else if (value.Key == "c") { C = value.Value; nAndCSet = true; } } if (nAndCSet) { classification = new SVMClassifier(data, kernel, n, C); } else { classification = new SVMClassifier(data, kernel); } }