Changeset 14891 for branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/KernelRidgeRegression/KernelFunctions/ThinPlatePolysplineKernel.cs
- Timestamp:
- 04/26/17 11:06:51 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/RBFRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/KernelRidgeRegression/KernelFunctions/ThinPlatePolysplineKernel.cs
r14887 r14891 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.Data; 26 using HeuristicLab.Parameters; 25 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 28 … … 28 30 [StorableClass] 29 31 // conditionally positive definite. (need to add polynomials) see http://num.math.uni-goettingen.de/schaback/teaching/sc.pdf 30 [Item("ThinPlatePolysplineKernel", "A kernel function that uses the ThinPlatePolyspline function ||x-c||^(2*Beta)*log(||x-c||^Beta)")]32 [Item("ThinPlatePolysplineKernel", "A kernel function that uses the ThinPlatePolyspline function (||x-c||/Beta)^(Degree)*log(||x-c||/Beta) as described in \"Thin-Plate Spline Radial Basis Function Scheme for Advection-Diffusion Problems\" with beta as a scaling parameter.")] 31 33 public class ThinPlatePolysplineKernel : KernelBase { 34 35 #region Parameternames 36 private const string DegreeParameterName = "Degree"; 37 #endregion 38 #region Parameterproperties 39 public IFixedValueParameter<DoubleValue> DegreeParameter 40 { 41 get { return Parameters[DegreeParameterName] as IFixedValueParameter<DoubleValue>; } 42 } 43 #endregion 44 #region Properties 45 public DoubleValue Degree 46 { 47 get { return DegreeParameter.Value; } 48 } 49 #endregion 50 32 51 #region HLConstructors & Boilerplate 33 52 [StorableConstructor] … … 37 56 protected ThinPlatePolysplineKernel(ThinPlatePolysplineKernel original, Cloner cloner) : base(original, cloner) { } 38 57 public ThinPlatePolysplineKernel() { 58 Parameters.Add(new FixedValueParameter<DoubleValue>(DegreeParameterName, "The degree of the kernel. Needs to be greater than zero.", new DoubleValue(2.0))); 39 59 } 40 60 public override IDeepCloneable Clone(Cloner cloner) { … … 45 65 protected override double Get(double norm) { 46 66 var beta = Beta.Value; 47 if (Math.Pow(norm, beta) < 0) return double.NaN; 48 return Math.Pow(norm, 2 * beta) * Math.Log(1 + Math.Pow(norm, beta)); 67 if (Math.Abs(beta) < double.Epsilon) return double.NaN; 68 var d = norm / beta; 69 if (Math.Abs(d) < double.Epsilon) return 0; 70 return Math.Pow(d, Degree.Value) * Math.Log(d); 49 71 } 50 72 73 // (Degree/beta) * (norm/beta)^Degree * log(norm/beta) 51 74 protected override double GetGradient(double norm) { 52 75 var beta = Beta.Value; 53 if (Math.Pow(norm, beta) <= 0) return double.NaN; 54 return 2 * Math.Log(norm) * Math.Pow(norm, 2 * beta) * Math.Log(1 + Math.Pow(norm, beta)) + Math.Pow(norm, 3 * beta) * Math.Log(norm) / (Math.Pow(norm, beta) + 1); 76 if (Math.Abs(beta) < double.Epsilon) return double.NaN; 77 var d = norm / beta; 78 if (Math.Abs(d) < double.Epsilon) return 0; 79 return Degree.Value / beta * Math.Pow(d, Degree.Value) * Math.Log(d); 55 80 } 56 81 }
Note: See TracChangeset
for help on using the changeset viewer.