Changeset 16387
- Timestamp:
- 12/15/18 12:12:13 (6 years ago)
- Location:
- stable
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk merged: 15739,16168
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.DataAnalysis
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Algorithms.DataAnalysis merged: 15739,16168
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.DataAnalysis/3.4
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Algorithms.DataAnalysis/3.4 merged: 15739,16168
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleModel.cs
r15584 r16387 36 36 public sealed class NeuralNetworkEnsembleModel : ClassificationModel, INeuralNetworkEnsembleModel { 37 37 38 private object mlpEnsembleLocker = new object(); 38 39 private alglib.mlpensemble mlpEnsemble; 39 public alglib.mlpensemble MultiLayerPerceptronEnsemble {40 get { return mlpEnsemble; }41 set {42 if (value != mlpEnsemble) {43 if (value == null) throw new ArgumentNullException();44 mlpEnsemble = value;45 OnChanged(EventArgs.Empty);46 }47 }48 }49 40 50 41 public override IEnumerable<string> VariablesUsedForPrediction { … … 102 93 x[column] = inputData[row, column]; 103 94 } 104 alglib.mlpeprocess(mlpEnsemble, x, ref y); 95 // mlpeprocess writes data in mlpEnsemble and is therefore not thread-safe 96 lock (mlpEnsembleLocker) { 97 alglib.mlpeprocess(mlpEnsemble, x, ref y); 98 } 105 99 yield return y[0]; 106 100 } … … 119 113 x[column] = inputData[row, column]; 120 114 } 121 alglib.mlpeprocess(mlpEnsemble, x, ref y); 115 // mlpeprocess writes data in mlpEnsemble and is therefore not thread-safe 116 lock (mlpEnsembleLocker) { 117 alglib.mlpeprocess(mlpEnsemble, x, ref y); 118 } 122 119 // find class for with the largest probability value 123 120 int maxProbClassIndex = 0; … … 139 136 return new NeuralNetworkEnsembleClassificationSolution(this, new ClassificationEnsembleProblemData(problemData)); 140 137 } 141 142 #region events 143 public event EventHandler Changed; 144 private void OnChanged(EventArgs e) { 145 var handlers = Changed; 146 if (handlers != null) 147 handlers(this, e); 148 } 149 #endregion 150 138 151 139 #region persistence 152 140 [Storable] -
stable/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkModel.cs
r15584 r16387 36 36 public sealed class NeuralNetworkModel : ClassificationModel, INeuralNetworkModel { 37 37 38 private object mlpLocker = new object(); 38 39 private alglib.multilayerperceptron multiLayerPerceptron; 39 public alglib.multilayerperceptron MultiLayerPerceptron {40 get { return multiLayerPerceptron; }41 set {42 if (value != multiLayerPerceptron) {43 if (value == null) throw new ArgumentNullException();44 multiLayerPerceptron = value;45 OnChanged(EventArgs.Empty);46 }47 }48 }49 40 50 41 public override IEnumerable<string> VariablesUsedForPrediction { … … 106 97 x[column] = inputData[row, column]; 107 98 } 108 alglib.mlpprocess(multiLayerPerceptron, x, ref y); 99 // NOTE: mlpprocess changes data in multiLayerPerceptron and is therefore not thread-save! 100 lock (mlpLocker) { 101 alglib.mlpprocess(multiLayerPerceptron, x, ref y); 102 } 109 103 yield return y[0]; 110 104 } … … 112 106 113 107 public override IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) { 114 double[,] inputData = dataset.ToArray( 108 double[,] inputData = dataset.ToArray(allowedInputVariables, rows); 115 109 116 110 int n = inputData.GetLength(0); … … 123 117 x[column] = inputData[row, column]; 124 118 } 125 alglib.mlpprocess(multiLayerPerceptron, x, ref y); 119 // NOTE: mlpprocess changes data in multiLayerPerceptron and is therefore not thread-save! 120 lock (mlpLocker) { 121 alglib.mlpprocess(multiLayerPerceptron, x, ref y); 122 } 126 123 // find class for with the largest probability value 127 124 int maxProbClassIndex = 0; … … 144 141 } 145 142 146 #region events147 public event EventHandler Changed;148 private void OnChanged(EventArgs e) {149 var handlers = Changed;150 if (handlers != null)151 handlers(this, e);152 }153 #endregion154 155 143 #region persistence 156 144 [Storable]
Note: See TracChangeset
for help on using the changeset viewer.