Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/20/14 17:45:06 (10 years ago)
Author:
gkronber
Message:

#2125 fixed the bug that covariance functions returned the full gradient vector even when parameters are partially fixed.
changed the calculation of NN covariance and gradient to direct calculation (instead of AutoDiff)

File:
1 edited

Legend:

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

    r9456 r10489  
    3737      get { return (IValueParameter<DoubleArray>)Parameters["InverseLength"]; }
    3838    }
     39    private bool HasFixedInverseLengthParameter {
     40      get { return InverseLengthParameter.Value != null; }
     41    }
    3942
    4043    [StorableConstructor]
     
    5760
    5861    public int GetNumberOfParameters(int numberOfVariables) {
    59       if (InverseLengthParameter.Value == null)
     62      if (HasFixedInverseLengthParameter)
     63        return 0;
     64      else
    6065        return numberOfVariables;
    61       else
    62         return 0;
    6366    }
    6467
     
    7174    private void GetParameterValues(double[] p, out double[] inverseLength) {
    7275      // gather parameter values
    73       if (InverseLengthParameter.Value != null) {
     76      if (HasFixedInverseLengthParameter) {
    7477        inverseLength = InverseLengthParameter.Value.ToArray();
    7578      } else {
     
    8184      double[] inverseLength;
    8285      GetParameterValues(p, out inverseLength);
     86      var fixedInverseLength = HasFixedInverseLengthParameter;
    8387      // create functions
    8488      var cov = new ParameterizedCovarianceFunction();
    8589      cov.Covariance = (x, i, j) => Util.ScalarProd(x, i, j, inverseLength, columnIndices);
    8690      cov.CrossCovariance = (x, xt, i, j) => Util.ScalarProd(x, i, xt, j, inverseLength, columnIndices);
    87       cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, inverseLength, columnIndices);
     91      if (fixedInverseLength)
     92        cov.CovarianceGradient = (x, i, j) => Enumerable.Empty<double>();
     93      else
     94        cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, inverseLength, columnIndices);
    8895      return cov;
    8996    }
Note: See TracChangeset for help on using the changeset viewer.