Changeset 13784 for trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceNeuralNetwork.cs
 Timestamp:
 04/22/16 13:47:35 (5 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceNeuralNetwork.cs
r13721 r13784 140 140 141 141 // order of returned gradients must match the order in GetParameterValues! 142 private static I Enumerable<double> GetGradient(double[,] x, int i, int j, double length, double scale, int[] columnIndices,142 private static IList<double> GetGradient(double[,] x, int i, int j, double length, double scale, int[] columnIndices, 143 143 bool fixedLength, bool fixedScale) { 144 { 145 double sx = 1.0; 146 double s1 = 1.0; 147 double s2 = 1.0; 148 for (int c = 0; c < columnIndices.Length; c++) { 149 var col = columnIndices[c]; 150 sx += x[i, col] * x[j, col]; 151 s1 += x[i, col] * x[i, col]; 152 s2 += x[j, col] * x[j, col]; 153 } 154 var h = (length + s1) * (length + s2); 155 var f = sx / Math.Sqrt(h); 156 if (!fixedLength) { 157 yield return scale / Math.Sqrt(1.0  f * f) * ((length * sx * (2.0 * length + s1 + s2)) / Math.Pow(h, 3.0 / 2.0)); 158 } 159 if (!fixedScale) { 160 yield return 2.0 * scale * Math.Asin(f); 161 } 144 double sx = 1.0; 145 double s1 = 1.0; 146 double s2 = 1.0; 147 for (int c = 0; c < columnIndices.Length; c++) { 148 var col = columnIndices[c]; 149 sx += x[i, col] * x[j, col]; 150 s1 += x[i, col] * x[i, col]; 151 s2 += x[j, col] * x[j, col]; 162 152 } 153 var h = (length + s1) * (length + s2); 154 var f = sx / Math.Sqrt(h); 155 156 var g = new List<double>(2); 157 if (!fixedLength) g.Add(scale / Math.Sqrt(1.0  f * f) * ((length * sx * (2.0 * length + s1 + s2)) / Math.Pow(h, 3.0 / 2.0))); 158 if (!fixedScale) g.Add(2.0 * scale * Math.Asin(f)); 159 return g; 163 160 } 164 161 }
Note: See TracChangeset
for help on using the changeset viewer.