- Timestamp:
- 12/08/18 07:52:35 (6 years ago)
- Location:
- branches/2937_SymReg_AnalyticalQuotient/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
- Files:
-
- 3 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2937_SymReg_AnalyticalQuotient/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeToAutoDiffTermConverter.cs
r16083 r16353 85 85 diff: x => -(Math.Exp(-(x * x)) * Math.Sqrt(Math.Exp(x * x)) * x) / Math.Sqrt(2 * Math.PI)); 86 86 87 private static readonly Func<Term, UnaryFunc> rectifier = UnaryFunc.Factory( 88 eval: x => Math.Max(x, 0), 89 diff: x => x > 0 ? 1.0 : 0.0); 90 91 private static readonly Func<Term, UnaryFunc> leakyRectifier = UnaryFunc.Factory( 92 eval: x => Math.Max(x, 0.01 * x), 93 diff: x => x > 0 ? 1.0 : 0.01); 94 87 95 #endregion 88 96 … … 254 262 ConvertToAutoDiff(node.GetSubtree(0))); 255 263 } 264 if (node.Symbol is Rectifier) { 265 return rectifier(ConvertToAutoDiff(node.GetSubtree(0))); 266 } 267 if (node.Symbol is LeakyRectifier) { 268 return leakyRectifier(ConvertToAutoDiff(node.GetSubtree(0))); 269 } 270 if (node.Symbol is Softplus) { 271 return TermBuilder.Log(1.0 + TermBuilder.Exp(ConvertToAutoDiff(node.GetSubtree(0)))); 272 } 256 273 if (node.Symbol is StartSymbol) { 257 274 if (addLinearScalingTerms) { … … 296 313 !(n.Symbol is Subtraction) && 297 314 !(n.Symbol is Multiplication) && 315 !(n.Symbol is AnalyticalQuotient) && 316 !(n.Symbol is Rectifier) && 317 !(n.Symbol is LeakyRectifier) && 318 !(n.Symbol is Softplus) && 298 319 !(n.Symbol is Division) && 299 320 !(n.Symbol is Logarithm) && -
branches/2937_SymReg_AnalyticalQuotient/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/FullFunctionalExpressionGrammar.cs
r16083 r16353 93 93 sineIntegral.InitialFrequency = 0.0; 94 94 95 var rect = new Rectifier(); 96 var softplus = new Softplus(); 97 var leakyRect = new LeakyRectifier(); 98 95 99 var exp = new Exponential(); 96 100 var @if = new IfThenElse(); … … 126 130 var allSymbols = new List<Symbol>() { add, sub, mul, div, aq, mean, sin, cos, tan, log, square, pow, sqrt, root, exp, 127 131 airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral, 128 @if, gt, lt, and, or, not,xor, timeLag, integral, derivative, constant, variableSymbol, binFactorVariable, factorVariable, laggedVariable,autoregressiveVariable, variableCondition }; 132 @if, gt, lt, and, or, not,xor, timeLag, integral, derivative, constant, variableSymbol, binFactorVariable, factorVariable, laggedVariable,autoregressiveVariable, variableCondition, 133 softplus, rect, leakyRect}; 129 134 var unaryFunctionSymbols = new List<Symbol>() { square, sqrt, sin, cos, tan, log, exp, not, timeLag, integral, derivative, 130 135 airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral 136 , rect, softplus, leakyRect 131 137 }; 132 138 -
branches/2937_SymReg_AnalyticalQuotient/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
r16083 r16353 198 198 <Compile Include="SymbolicDataAnalysisSolutionImpactValuesCalculator.cs" /> 199 199 <Compile Include="Symbols\Addition.cs" /> 200 <Compile Include="Symbols\LeakyRectifier.cs" /> 201 <Compile Include="Symbols\Rectifier.cs" /> 202 <Compile Include="Symbols\SoftSum.cs" /> 200 203 <Compile Include="Symbols\And.cs" /> 201 204 <Compile Include="Symbols\AutoregressiveVariable.cs" /> -
branches/2937_SymReg_AnalyticalQuotient/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/OpCodes.cs
r16083 r16353 86 86 public const byte BinaryFactorVariable = 47; 87 87 public const byte AnalyticalQuotient = 48; 88 public const byte Rectifier = 49; 89 public const byte Softplus = 50; 90 public const byte LeakyRectifier = 51; 88 91 89 92 … … 137 140 { typeof(FactorVariable), OpCodes.FactorVariable }, 138 141 { typeof(BinaryFactorVariable), OpCodes.BinaryFactorVariable }, 139 {typeof(AnalyticalQuotient), OpCodes.AnalyticalQuotient } 142 {typeof(AnalyticalQuotient), OpCodes.AnalyticalQuotient }, 143 {typeof(Rectifier), OpCodes.Rectifier }, 144 {typeof(Softplus), OpCodes.Softplus}, 145 {typeof(LeakyRectifier), OpCodes.LeakyRectifier }, 140 146 }; 141 147 -
branches/2937_SymReg_AnalyticalQuotient/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs
r16083 r16353 346 346 } 347 347 instr.value = result; 348 } else if (instr.opCode == OpCodes.Rectifier) { 349 return Math.Max(code[instr.childIndex].value, 0.0); 350 } else if (instr.opCode == OpCodes.LeakyRectifier) { 351 var x = code[instr.childIndex].value; 352 if (x > 0) return x; else return 0.01 * x; 353 } else if (instr.opCode == OpCodes.Softplus) { 354 var x = code[instr.childIndex].value; 355 return Math.Log(1.0 + Math.Exp(x)); 348 356 } else if (instr.opCode == OpCodes.AND) { 349 357 double result = code[instr.childIndex].value;
Note: See TracChangeset
for help on using the changeset viewer.