Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8419


Ignore:
Timestamp:
08/06/12 18:52:22 (12 years ago)
Author:
gkronber
Message:

#1902 changed initialization of hyperparameter vector for GPR using a PRNG

Location:
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4
Files:
4 edited

Legend:

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

    r8401 r8419  
    3838    private const string ProblemDataParameterName = "ProblemData";
    3939    private const string HyperparameterParameterName = "Hyperparameter";
     40    private const string RandomParameterName = "Random";
    4041
    4142    #region Parameter Properties
     
    4950    public ILookupParameter<IDataAnalysisProblemData> ProblemDataParameter {
    5051      get { return (ILookupParameter<IDataAnalysisProblemData>)Parameters[ProblemDataParameterName]; }
     52    }
     53    public ILookupParameter<IRandom> RandomParameter {
     54      get { return (ILookupParameter<IRandom>)Parameters[RandomParameterName]; }
    5155    }
    5256    // out
     
    7175      Parameters.Add(new LookupParameter<ICovarianceFunction>(CovarianceFunctionParameterName, "The covariance function for the Gaussian process model."));
    7276      Parameters.Add(new LookupParameter<IDataAnalysisProblemData>(ProblemDataParameterName, "The input data for the Gaussian process."));
     77      Parameters.Add(new LookupParameter<IRandom>(RandomParameterName, "The pseudo random number generator to use for initializing the hyperparameter vector."));
    7378      // out
    7479      Parameters.Add(new LookupParameter<RealVector>(HyperparameterParameterName, "The initial hyperparameter vector for the Gaussian process model."));
     
    8388      int l = 1 + MeanFunction.GetNumberOfParameters(inputVariablesCount) +
    8489              CovarianceFunction.GetNumberOfParameters(inputVariablesCount);
    85       HyperparameterParameter.ActualValue = new RealVector(l);
     90      var r = new RealVector(l);
     91      var rand = RandomParameter.ActualValue;
     92      for (int i = 0; i < r.Length; i++)
     93        r[i] = rand.NextDouble() * 4 - 2;
     94
     95      HyperparameterParameter.ActualValue = r;
    8696      return base.Apply();
    8797    }
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegression.cs

    r8401 r8419  
    5555    private const string MinimizationIterationsParameterName = "Iterations";
    5656    private const string ApproximateGradientsParameterName = "ApproximateGradients";
     57    private const string SeedParameterName = "Seed";
     58    private const string SetSeedRandomlyParameterName = "SetSeedRandomly";
    5759
    5860    #region parameter properties
     
    6567    public IValueParameter<IntValue> MinimizationIterationsParameter {
    6668      get { return (IValueParameter<IntValue>)Parameters[MinimizationIterationsParameterName]; }
     69    }
     70    public IValueParameter<IntValue> SeedParameter {
     71      get { return (IValueParameter<IntValue>)Parameters[SeedParameterName]; }
     72    }
     73    public IValueParameter<BoolValue> SetSeedRandomlyParameter {
     74      get { return (IValueParameter<BoolValue>)Parameters[SetSeedRandomlyParameterName]; }
    6775    }
    6876    #endregion
     
    8088      get { return MinimizationIterationsParameter.Value.Value; }
    8189    }
     90    public int Seed { get { return SeedParameter.Value.Value; } set { SeedParameter.Value.Value = value; } }
     91    public bool SetSeedRandomly { get { return SetSeedRandomlyParameter.Value.Value; } set { SetSeedRandomlyParameter.Value.Value = value; } }
    8292    #endregion
     93
    8394    [StorableConstructor]
    8495    private GaussianProcessRegression(bool deserializing) : base(deserializing) { }
     
    101112        new ItemSet<ICovarianceFunction>(covFunctions), covFunctions.First()));
    102113      Parameters.Add(new ValueParameter<IntValue>(MinimizationIterationsParameterName, "The number of iterations for likelihood optimization with LM-BFGS.", new IntValue(20)));
     114      Parameters.Add(new ValueParameter<IntValue>(SeedParameterName, "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
     115      Parameters.Add(new ValueParameter<BoolValue>(SetSeedRandomlyParameterName, "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
     116
    103117      Parameters.Add(new ValueParameter<BoolValue>(ApproximateGradientsParameterName, "Indicates that gradients should not be approximated (necessary for LM-BFGS).", new BoolValue(false)));
    104118      Parameters[ApproximateGradientsParameterName].Hidden = true; // should not be changed
    105119
     120      var randomCreator = new HeuristicLab.Random.RandomCreator();
    106121      var gpInitializer = new GaussianProcessHyperparameterInitializer();
    107122      var bfgsInitializer = new LbfgsInitializer();
     
    115130      var solutionCreator = new GaussianProcessRegressionSolutionCreator();
    116131
    117       OperatorGraph.InitialOperator = gpInitializer;
     132      OperatorGraph.InitialOperator = randomCreator;
     133      randomCreator.SeedParameter.ActualName = SeedParameterName;
     134      randomCreator.SeedParameter.Value = null;
     135      randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameterName;
     136      randomCreator.SetSeedRandomlyParameter.Value = null;
     137      randomCreator.Successor = gpInitializer;
    118138
    119139      gpInitializer.CovarianceFunctionParameter.ActualName = CovarianceFunctionParameterName;
     
    121141      gpInitializer.ProblemDataParameter.ActualName = Problem.ProblemDataParameter.Name;
    122142      gpInitializer.HyperparameterParameter.ActualName = modelCreator.HyperparameterParameter.Name;
     143      gpInitializer.RandomParameter.ActualName = randomCreator.RandomParameter.Name;
    123144      gpInitializer.Successor = bfgsInitializer;
    124145
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj

    r8417 r8419  
    304304      <Private>False</Private>
    305305    </ProjectReference>
     306    <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj">
     307      <Project>{F4539FB6-4708-40C9-BE64-0A1390AEA197}</Project>
     308      <Name>HeuristicLab.Random-3.3</Name>
     309      <Private>False</Private>
     310    </ProjectReference>
    306311  </ItemGroup>
    307312  <ItemGroup>
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Plugin.cs.frame

    r8401 r8419  
    4747  [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic.Regression", "3.4")]
    4848  [PluginDependency("HeuristicLab.LibSVM", "1.6.3")]
     49  [PluginDependency("HeuristicLab.Random", "3.3")]
    4950  public class HeuristicLabAlgorithmsDataAnalysisPlugin : PluginBase {
    5051  }
Note: See TracChangeset for help on using the changeset viewer.