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/CovarianceProduct.cs

    r13721 r13784  
    2323using System.Collections.Generic;
    2424using System.Linq;
    25 using System.Linq.Expressions;
    2625using HeuristicLab.Common;
    2726using HeuristicLab.Core;
     
    9392    }
    9493
    95     public static IEnumerable<double> GetGradient(double[,] x, int i, int j, List<ParameterizedCovarianceFunction> factorFunctions) {
     94    public static IList<double> GetGradient(double[,] x, int i, int j, List<ParameterizedCovarianceFunction> factorFunctions) {
    9695      var covariances = factorFunctions.Select(f => f.Covariance(x, i, j)).ToArray();
     96      var gr = new List<double>(factorFunctions.Sum(f => f.CovarianceGradient(x, i, j).Count));
    9797      for (int ii = 0; ii < factorFunctions.Count; ii++) {
    9898        foreach (var g in factorFunctions[ii].CovarianceGradient(x, i, j)) {
     
    100100          for (int jj = 0; jj < covariances.Length; jj++)
    101101            if (ii != jj) res *= covariances[jj];
    102           yield return res;
     102          gr.Add(res);
    103103        }
    104104      }
     105      return gr;
    105106    }
    106107  }
Note: See TracChangeset for help on using the changeset viewer.