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

    r9544 r10489  
    3737      get { return (IValueParameter<DoubleValue>)Parameters["Scale"]; }
    3838    }
     39    private bool HasFixedScaleParameter {
     40      get { return ScaleParameter.Value != null; }
     41    }
    3942
    4043    [StorableConstructor]
     
    6063
    6164    public int GetNumberOfParameters(int numberOfVariables) {
    62       return ScaleParameter.Value != null ? 0 : 1;
     65      return HasFixedScaleParameter ? 0 : 1;
    6366    }
    6467
     
    7275      int c = 0;
    7376      // gather parameter values
    74       if (ScaleParameter.Value != null) {
     77      if (HasFixedScaleParameter) {
    7578        scale = ScaleParameter.Value.Value;
    7679      } else {
     
    8487      double scale;
    8588      GetParameterValues(p, out scale);
     89      var fixedScale = HasFixedScaleParameter;
    8690      // create functions
    8791      var cov = new ParameterizedCovarianceFunction();
    8892      cov.Covariance = (x, i, j) => i == j ? scale : 0.0;
    8993      cov.CrossCovariance = (x, xt, i, j) => Util.SqrDist(x, i, xt, j, 1.0, columnIndices) < 1e-9 ? scale : 0.0;
    90       cov.CovarianceGradient = (x, i, j) => Enumerable.Repeat(i == j ? 2.0 * scale : 0.0, 1);
     94      if (fixedScale)
     95        cov.CovarianceGradient = (x, i, j) => Enumerable.Empty<double>();
     96      else
     97        cov.CovarianceGradient = (x, i, j) => Enumerable.Repeat(i == j ? 2.0 * scale : 0.0, 1);
    9198      return cov;
    9299    }
Note: See TracChangeset for help on using the changeset viewer.