Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/20/18 15:27:44 (6 years ago)
Author:
gkronber
Message:

#2891: incorporated feedback from review, made NeuralNetworkEnsembleModel and NeuralNetworkModel readonly. This is a breaking change to the API

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

Legend:

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

    r15739 r16168  
    3636  public sealed class NeuralNetworkEnsembleModel : ClassificationModel, INeuralNetworkEnsembleModel {
    3737
     38    private object mlpEnsembleLocker = new object();
    3839    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     }
    4940
    5041    public override IEnumerable<string> VariablesUsedForPrediction {
     
    10394        }
    10495        // mlpeprocess writes data in mlpEnsemble and is therefore not thread-safe
    105         lock (mlpEnsemble) {
     96        lock (mlpEnsembleLocker) {
    10697          alglib.mlpeprocess(mlpEnsemble, x, ref y);
    10798        }
     
    123114        }
    124115        // mlpeprocess writes data in mlpEnsemble and is therefore not thread-safe
    125         lock (mlpEnsemble) {
     116        lock (mlpEnsembleLocker) {
    126117          alglib.mlpeprocess(mlpEnsemble, x, ref y);
    127118        }
     
    145136      return new NeuralNetworkEnsembleClassificationSolution(this, new ClassificationEnsembleProblemData(problemData));
    146137    }
    147 
    148     #region events
    149     public event EventHandler Changed;
    150     private void OnChanged(EventArgs e) {
    151       var handlers = Changed;
    152       if (handlers != null)
    153         handlers(this, e);
    154     }
    155     #endregion
    156 
     138   
    157139    #region persistence
    158140    [Storable]
  • trunk/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkModel.cs

    r15739 r16168  
    3636  public sealed class NeuralNetworkModel : ClassificationModel, INeuralNetworkModel {
    3737
     38    private object mlpLocker = new object();
    3839    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     }
    4940
    5041    public override IEnumerable<string> VariablesUsedForPrediction {
     
    10798        }
    10899        // NOTE: mlpprocess changes data in multiLayerPerceptron and is therefore not thread-save!
    109         lock (multiLayerPerceptron) {
     100        lock (mlpLocker) {
    110101          alglib.mlpprocess(multiLayerPerceptron, x, ref y);
    111102        }
     
    127118        }
    128119        // NOTE: mlpprocess changes data in multiLayerPerceptron and is therefore not thread-save!
    129         lock (multiLayerPerceptron) {
     120        lock (mlpLocker) {
    130121          alglib.mlpprocess(multiLayerPerceptron, x, ref y);
    131122        }
     
    150141    }
    151142
    152     #region events
    153     public event EventHandler Changed;
    154     private void OnChanged(EventArgs e) {
    155       var handlers = Changed;
    156       if (handlers != null)
    157         handlers(this, e);
    158     }
    159     #endregion
    160 
    161143    #region persistence
    162144    [Storable]
Note: See TracChangeset for help on using the changeset viewer.