Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/23/22 13:10:34 (3 years ago)
Author:
pfleck
Message:

#3040 smaller fixes and some code cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeToTensorConverter.cs

    r18239 r18240  
    5858
    5959        inputFeatures = converter.inputFeatures;
    60         target = InputFeatureToTensor(problemData.TargetVariable, problemData, rows);
     60        target = tf.reshape(InputFeatureToTensor(problemData.TargetVariable, problemData, rows), new Shape(-1));
    6161        variables = converter.variables;
    6262
     
    201201      } else if (node.Symbol is StartSymbol) {
    202202        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));
    204204          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));
    206206          var beta = tf.Variable(beta_arr, name: "beta", dtype: DataType);
    207207          variables.Add(node, new[] { beta, alpha });
     
    272272      if (node.Symbol is Division) {
    273273        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];
    276275        return terms.Aggregate((a, b) => a / b);
    277276      }
     
    285284        var x1 = EvaluateNode(node.GetSubtree(0));
    286285        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);
    288287        //return x1 / tf.pow(1.0 + x2 * x2, 0.5);
    289288      }
     
    297296        return tf.pow(
    298297          (float)Math.E,
    299           //Math.E,
    300298          EvaluateNode(node.GetSubtree(0)));
    301299      }
     
    313311      if (node.Symbol is Cube) {
    314312        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);
    317314      }
    318315
    319316      if (node.Symbol is CubeRoot) {
    320317        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);
    323319        // TODO
    324320        // 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.