Changeset 17721 for branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression
- Timestamp:
- 08/11/20 13:39:48 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/TensorFlowConstantOptimizationEvaluator.cs
r17502 r17721 56 56 private static readonly TF_DataType DataType = tf.float32; 57 57 58 #region Parameter Properties58 #region Parameter Properties 59 59 public IFixedValueParameter<IntValue> ConstantOptimizationIterationsParameter { 60 60 get { return (IFixedValueParameter<IntValue>)Parameters[MaximumIterationsName]; } … … 63 63 get { return (IFixedValueParameter<DoubleValue>)Parameters[LearningRateName]; } 64 64 } 65 #endregion66 67 #region Properties65 #endregion 66 67 #region Properties 68 68 public int ConstantOptimizationIterations { 69 69 get { return ConstantOptimizationIterationsParameter.Value.Value; } … … 72 72 get { return LearningRateParameter.Value.Value; } 73 73 } 74 #endregion74 #endregion 75 75 76 76 public TensorFlowConstantOptimizationEvaluator() … … 125 125 var target = tf.placeholder(DataType, new TensorShape(numRows), name: problemData.TargetVariable); 126 126 // MSE 127 var cost = tf.reduce_mean(tf.square( prediction - target));127 var cost = tf.reduce_mean(tf.square(target - prediction)); 128 128 129 129 var optimizer = tf.train.AdamOptimizer((float)learningRate); … … 144 144 if (problemData.Dataset.VariableHasType<double>(variableName)) { 145 145 var data = problemData.Dataset.GetDoubleValues(variableName, rows).Select(x => (float)x).ToArray(); 146 variablesFeed.Add(variable, np.array(data , copy: false).reshape(numRows, 1));146 variablesFeed.Add(variable, np.array(data).reshape(numRows, 1)); 147 147 } else if (problemData.Dataset.VariableHasType<DoubleVector>(variableName)) { 148 148 var data = problemData.Dataset.GetDoubleVectorValues(variableName, rows).Select(x => x.Select(y => (float)y).ToArray()).ToArray(); … … 152 152 } 153 153 var targetData = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows).Select(x => (float)x).ToArray(); 154 variablesFeed.Add(target, np.array(targetData , copy: false));154 variablesFeed.Add(target, np.array(targetData)); 155 155 156 156
Note: See TracChangeset
for help on using the changeset viewer.