Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/22/16 13:47:35 (8 years ago)
Author:
pfleck
Message:

#2591 Made the creation of a GaussianProcessModel faster by avoiding additional iterators during calculation of the hyperparameter gradients.
The gradients of the hyperparameters are now calculated in one sweep and returned as IList, instead of returning an iterator (with yield return).
This avoids a large amount of Move-calls of the iterator, especially for covariance functions with a lot of hyperparameters.
Besides, the signature of the CovarianceGradientFunctionDelegate is changed, to return an IList instead of an IEnumerable to avoid unnececary ToList or ToArray calls.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovariancePolynomial.cs

    r13721 r13784  
    121121    }
    122122
    123     private static IEnumerable<double> GetGradient(double[,] x, int i, int j, double c, double scale, int degree, int[] columnIndices,
     123    private static IList<double> GetGradient(double[,] x, int i, int j, double c, double scale, int degree, int[] columnIndices,
    124124      bool fixedConst, bool fixedScale) {
    125125      double s = Util.ScalarProd(x, i, j, columnIndices, 1.0);
    126       if (!fixedConst) yield return c * degree * scale * Math.Pow(c + s, degree - 1);
    127       if (!fixedScale) yield return 2 * scale * Math.Pow(c + s, degree);
     126      var g = new List<double>(2);
     127      if (!fixedConst) g.Add(c * degree * scale * Math.Pow(c + s, degree - 1));
     128      if (!fixedScale) g.Add(2 * scale * Math.Pow(c + s, degree));
     129      return g;
    128130    }
    129131  }
Note: See TracChangeset for help on using the changeset viewer.