Changeset 18240 for branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeToTensorConverter.cs
- Timestamp:
- 03/23/22 13:10:34 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeToTensorConverter.cs
r18239 r18240 58 58 59 59 inputFeatures = converter.inputFeatures; 60 target = InputFeatureToTensor(problemData.TargetVariable, problemData, rows);60 target = tf.reshape(InputFeatureToTensor(problemData.TargetVariable, problemData, rows), new Shape(-1)); 61 61 variables = converter.variables; 62 62 … … 201 201 } else if (node.Symbol is StartSymbol) { 202 202 if (addLinearScalingTerms) { 203 var alpha_arr = np.array( 1.0f).reshape(new Shape(1, 1));203 var alpha_arr = np.array((float)1.0).reshape(new Shape(1, 1)); 204 204 var alpha = tf.Variable(alpha_arr, name: "alpha", dtype: DataType); 205 var beta_arr = np.array( 0.0f).reshape(new Shape(1, 1));205 var beta_arr = np.array((float)0.0).reshape(new Shape(1, 1)); 206 206 var beta = tf.Variable(beta_arr, name: "beta", dtype: DataType); 207 207 variables.Add(node, new[] { beta, alpha }); … … 272 272 if (node.Symbol is Division) { 273 273 var terms = node.Subtrees.Select(EvaluateNode).ToList(); 274 //if (terms.Count == 1) return 1.0f / terms[0]; 275 if (terms.Count == 1) return 1.0 / terms[0]; 274 if (terms.Count == 1) return (float)1.0 / terms[0]; 276 275 return terms.Aggregate((a, b) => a / b); 277 276 } … … 285 284 var x1 = EvaluateNode(node.GetSubtree(0)); 286 285 var x2 = EvaluateNode(node.GetSubtree(1)); 287 return x1 / tf.pow( 1.0f + x2 * x2, 0.5f);286 return x1 / tf.pow((float)1.0 + x2 * x2, (float)0.5); 288 287 //return x1 / tf.pow(1.0 + x2 * x2, 0.5); 289 288 } … … 297 296 return tf.pow( 298 297 (float)Math.E, 299 //Math.E,300 298 EvaluateNode(node.GetSubtree(0))); 301 299 } … … 313 311 if (node.Symbol is Cube) { 314 312 return tf.pow( 315 EvaluateNode(node.GetSubtree(0)), 3.0f); 316 //ConvertNode(node.GetSubtree(0)), 3.0); 313 EvaluateNode(node.GetSubtree(0)), (float)3.0); 317 314 } 318 315 319 316 if (node.Symbol is CubeRoot) { 320 317 return tf.pow( 321 EvaluateNode(node.GetSubtree(0)), 1.0f / 3.0f); 322 //ConvertNode(node.GetSubtree(0)), 1.0 / 3.0); 318 EvaluateNode(node.GetSubtree(0)), (float)1.0 / (float)3.0); 323 319 // TODO 324 320 // f: x < 0 ? -Math.Pow(-x, 1.0 / 3) : Math.Pow(x, 1.0 / 3),
Note: See TracChangeset
for help on using the changeset viewer.