Changeset 15739


Ignore:
Timestamp:
02/08/18 14:16:39 (17 months ago)
Author:
gkronber
Message:

#2891: fixed bug in NN and NN ensemble using a simple lock for processing an input.

Location:
trunk/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleModel.cs

    r15583 r15739  
    102102          x[column] = inputData[row, column];
    103103        }
    104         alglib.mlpeprocess(mlpEnsemble, x, ref y);
     104        // mlpeprocess writes data in mlpEnsemble and is therefore not thread-safe
     105        lock (mlpEnsemble) {
     106          alglib.mlpeprocess(mlpEnsemble, x, ref y);
     107        }
    105108        yield return y[0];
    106109      }
     
    119122          x[column] = inputData[row, column];
    120123        }
    121         alglib.mlpeprocess(mlpEnsemble, x, ref y);
     124        // mlpeprocess writes data in mlpEnsemble and is therefore not thread-safe
     125        lock (mlpEnsemble) {
     126          alglib.mlpeprocess(mlpEnsemble, x, ref y);
     127        }
    122128        // find class for with the largest probability value
    123129        int maxProbClassIndex = 0;
  • trunk/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkModel.cs

    r15583 r15739  
    106106          x[column] = inputData[row, column];
    107107        }
    108         alglib.mlpprocess(multiLayerPerceptron, x, ref y);
     108        // NOTE: mlpprocess changes data in multiLayerPerceptron and is therefore not thread-save!
     109        lock (multiLayerPerceptron) {
     110          alglib.mlpprocess(multiLayerPerceptron, x, ref y);
     111        }
    109112        yield return y[0];
    110113      }
     
    112115
    113116    public override IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {
    114       double[,] inputData = dataset.ToArray( allowedInputVariables, rows);
     117      double[,] inputData = dataset.ToArray(allowedInputVariables, rows);
    115118
    116119      int n = inputData.GetLength(0);
     
    123126          x[column] = inputData[row, column];
    124127        }
    125         alglib.mlpprocess(multiLayerPerceptron, x, ref y);
     128        // NOTE: mlpprocess changes data in multiLayerPerceptron and is therefore not thread-save!
     129        lock (multiLayerPerceptron) {
     130          alglib.mlpprocess(multiLayerPerceptron, x, ref y);
     131        }
    126132        // find class for with the largest probability value
    127133        int maxProbClassIndex = 0;
Note: See TracChangeset for help on using the changeset viewer.