Changeset 12969 for branches/gteufl/HeuristicLab.Algorithms.GradientDescent/3.3/LbfgsUpdateResults.cs
- Timestamp:
- 09/25/15 14:39:59 (9 years ago)
- Location:
- branches/gteufl
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gteufl
- Property svn:ignore
-
old new 8 8 FxCopResults.txt 9 9 Google.ProtocolBuffers-0.9.1.dll 10 Google.ProtocolBuffers-2.4.1.473.dll 10 11 HeuristicLab 3.3.5.1.ReSharper.user 11 12 HeuristicLab 3.3.6.0.ReSharper.user 12 13 HeuristicLab.4.5.resharper.user 13 14 HeuristicLab.ExtLibs.6.0.ReSharper.user 15 HeuristicLab.Scripting.Development 14 16 HeuristicLab.resharper.user 15 17 ProtoGen.exe … … 17 19 _ReSharper.HeuristicLab 18 20 _ReSharper.HeuristicLab 3.3 21 _ReSharper.HeuristicLab 3.3 Tests 19 22 _ReSharper.HeuristicLab.ExtLibs 20 23 bin 21 24 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll 25 obj
-
- Property svn:mergeinfo changed
-
Property
svn:global-ignores
set to
*.nuget
packages
- Property svn:ignore
-
branches/gteufl/HeuristicLab.Algorithms.GradientDescent/3.3/LbfgsUpdateResults.cs
r9456 r12969 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 37 37 private const string StateParameterName = "State"; 38 38 private const string ApproximateGradientsParameterName = "ApproximateGradients"; 39 private const string MaximizationParameterName = "Maximization"; 39 40 40 41 #region Parameter Properties … … 51 52 get { return (ILookupParameter<LbfgsState>)Parameters[StateParameterName]; } 52 53 } 54 public ILookupParameter<BoolValue> MaximizationParameter { 55 get { return (ILookupParameter<BoolValue>)Parameters[MaximizationParameterName]; } 56 } 53 57 #endregion 54 58 … … 58 62 private DoubleValue Quality { get { return QualityParameter.ActualValue; } } 59 63 private LbfgsState State { get { return StateParameter.ActualValue; } } 64 65 private BoolValue Maximization { 66 get { 67 // BackwardsCompatibility3.3 68 #region Backwards compatible code, remove with 3.4 69 // the parameter is new, previously we assumed minimization problems 70 if (MaximizationParameter.ActualValue == null) return new BoolValue(false); 71 #endregion 72 return MaximizationParameter.ActualValue; 73 } 74 } 75 60 76 #endregion 61 77 … … 70 86 Parameters.Add(new LookupParameter<BoolValue>(ApproximateGradientsParameterName, 71 87 "Flag that indicates if gradients should be approximated.")); 88 Parameters.Add(new LookupParameter<BoolValue>(MaximizationParameterName, "Flag that indicates if we solve a maximization problem.")); 72 89 // in & out 73 90 Parameters.Add(new LookupParameter<LbfgsState>(StateParameterName, "The state of the LM-BFGS algorithm.")); 91 } 92 93 [StorableHook(HookType.AfterDeserialization)] 94 private void AfterDeserialization() { 95 // BackwardsCompatibility3.3 96 97 #region Backwards compatible code, remove with 3.4 98 if (!Parameters.ContainsKey(MaximizationParameterName)) { 99 // previous behaviour defaulted to minimization 100 Parameters.Add(new LookupParameter<BoolValue>(MaximizationParameterName, "Flag that indicates if we solve a maximization problem.")); 101 } 102 #endregion 74 103 } 75 104 … … 80 109 public override IOperation Apply() { 81 110 var state = State; 82 var f = Quality.Value; 111 var sign = Maximization.Value ? -1.0 : 1.0; 112 var f = sign * Quality.Value; 83 113 state.State.f = f; 84 114 if (!ApproximateGradients.Value) { 85 var g = QualityGradients. ToArray();115 var g = QualityGradients.Select(gi => sign * gi).ToArray(); 86 116 state.State.g = g; 87 117 }
Note: See TracChangeset
for help on using the changeset viewer.