Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6720


Ignore:
Timestamp:
09/08/11 13:40:48 (12 years ago)
Author:
gkronber
Message:

#1474 added (conditional) parameter hiding

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

Legend:

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

    r6649 r6720  
    113113    private NeuralNetworkClassification(NeuralNetworkClassification original, Cloner cloner)
    114114      : base(original, cloner) {
     115      RegisterEventHandlers();
    115116    }
    116117    public NeuralNetworkClassification()
    117118      : base() {
    118       var validHiddenLayerValues = new ItemSet<IntValue>(new IntValue[] { new IntValue(0), new IntValue(1), new IntValue(2) });
     119      var validHiddenLayerValues = new ItemSet<IntValue>(new IntValue[] {
     120        (IntValue)new IntValue(0).AsReadOnly(),
     121        (IntValue)new IntValue(1).AsReadOnly(),
     122        (IntValue)new IntValue(2).AsReadOnly() });
    119123      var selectedHiddenLayerValue = (from v in validHiddenLayerValues
    120124                                      where v.Value == 1
     
    127131      Parameters.Add(new FixedValueParameter<IntValue>(RestartsParameterName, "The number of restarts for learning.", new IntValue(2)));
    128132
     133      RestartsParameter.Hidden = true;
     134      NodesInSecondHiddenLayerParameter.Hidden = true;
     135
     136      RegisterEventHandlers();
     137
    129138      Problem = new ClassificationProblem();
    130139    }
     140
     141    private void RegisterEventHandlers() {
     142      HiddenLayersParameter.Value.ValueChanged += HiddenLayersParameterValueValueChanged;
     143      HiddenLayersParameter.ValueChanged += HiddenLayersParameterValueChanged;
     144    }
     145
    131146    [StorableHook(HookType.AfterDeserialization)]
    132     private void AfterDeserialization() { }
     147    private void AfterDeserialization() {
     148      RegisterEventHandlers();
     149    }
    133150
    134151    public override IDeepCloneable Clone(Cloner cloner) {
    135152      return new NeuralNetworkClassification(this, cloner);
     153    }
     154    private void HiddenLayersParameterValueChanged(object source, EventArgs e) {
     155      HiddenLayersParameter.Value.ValueChanged += HiddenLayersParameterValueValueChanged;
     156      HiddenLayersParameterValueValueChanged(this, EventArgs.Empty);
     157    }
     158
     159    private void HiddenLayersParameterValueValueChanged(object source, EventArgs e) {
     160      if (HiddenLayers == 0) {
     161        NodesInFirstHiddenLayerParameter.Hidden = true;
     162        NodesInSecondHiddenLayerParameter.Hidden = true;
     163      } else if (HiddenLayers == 1) {
     164        NodesInFirstHiddenLayerParameter.Hidden = false;
     165        NodesInSecondHiddenLayerParameter.Hidden = true;
     166      } else {
     167        NodesInFirstHiddenLayerParameter.Hidden = false;
     168        NodesInSecondHiddenLayerParameter.Hidden = false;
     169      }
    136170    }
    137171
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleClassification.cs

    r6649 r6720  
    127127    public NeuralNetworkEnsembleClassification()
    128128      : base() {
    129       var validHiddenLayerValues = new ItemSet<IntValue>(new IntValue[] { new IntValue(0), new IntValue(1), new IntValue(2) });
     129        var validHiddenLayerValues = new ItemSet<IntValue>(new IntValue[] {
     130        (IntValue)new IntValue(0).AsReadOnly(),
     131        (IntValue)new IntValue(1).AsReadOnly(),
     132        (IntValue)new IntValue(2).AsReadOnly() });
    130133      var selectedHiddenLayerValue = (from v in validHiddenLayerValues
    131134                                      where v.Value == 1
     
    139142      Parameters.Add(new FixedValueParameter<IntValue>(RestartsParameterName, "The number of restarts for learning.", new IntValue(2)));
    140143
     144      HiddenLayersParameter.Hidden = true;
     145      NodesInFirstHiddenLayerParameter.Hidden = true;
     146      NodesInSecondHiddenLayerParameter.Hidden = true;
     147      RestartsParameter.Hidden = true;
     148
    141149      Problem = new ClassificationProblem();
    142150    }
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleRegression.cs

    r6649 r6720  
    127127    public NeuralNetworkEnsembleRegression()
    128128      : base() {
    129       var validHiddenLayerValues = new ItemSet<IntValue>(new IntValue[] { new IntValue(0), new IntValue(1), new IntValue(2) });
     129        var validHiddenLayerValues = new ItemSet<IntValue>(new IntValue[] {
     130        (IntValue)new IntValue(0).AsReadOnly(),
     131        (IntValue)new IntValue(1).AsReadOnly(),
     132        (IntValue)new IntValue(2).AsReadOnly() });
    130133      var selectedHiddenLayerValue = (from v in validHiddenLayerValues
    131134                                      where v.Value == 1
     
    138141      Parameters.Add(new FixedValueParameter<IntValue>(NodesInSecondHiddenLayerParameterName, "The number of nodes in the second hidden layer. This value is not used if the number of hidden layers is zero or one.", new IntValue(100)));
    139142      Parameters.Add(new FixedValueParameter<IntValue>(RestartsParameterName, "The number of restarts for learning.", new IntValue(2)));
     143
     144      HiddenLayersParameter.Hidden = true;
     145      NodesInFirstHiddenLayerParameter.Hidden = true;
     146      NodesInSecondHiddenLayerParameter.Hidden = true;
     147      RestartsParameter.Hidden = true;
    140148
    141149      Problem = new RegressionProblem();
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkRegression.cs

    r6719 r6720  
    113113    private NeuralNetworkRegression(NeuralNetworkRegression original, Cloner cloner)
    114114      : base(original, cloner) {
     115      RegisterEventHandlers();
    115116    }
    116117    public NeuralNetworkRegression()
    117118      : base() {
    118       var validHiddenLayerValues = new ItemSet<IntValue>(new IntValue[] { new IntValue(0), new IntValue(1), new IntValue(2) });
     119      var validHiddenLayerValues = new ItemSet<IntValue>(new IntValue[] {
     120        (IntValue)new IntValue(0).AsReadOnly(),
     121        (IntValue)new IntValue(1).AsReadOnly(),
     122        (IntValue)new IntValue(2).AsReadOnly() });
    119123      var selectedHiddenLayerValue = (from v in validHiddenLayerValues
    120124                                      where v.Value == 1
     
    127131      Parameters.Add(new FixedValueParameter<IntValue>(RestartsParameterName, "The number of restarts for learning.", new IntValue(2)));
    128132
     133      RestartsParameter.Hidden = true;
     134      NodesInSecondHiddenLayerParameter.Hidden = true;
     135
     136      RegisterEventHandlers();
     137
    129138      Problem = new RegressionProblem();
    130139    }
     140
     141    private void RegisterEventHandlers() {
     142      HiddenLayersParameter.Value.ValueChanged += HiddenLayersParameterValueValueChanged;
     143      HiddenLayersParameter.ValueChanged += HiddenLayersParameterValueChanged;
     144    }
     145
    131146    [StorableHook(HookType.AfterDeserialization)]
    132     private void AfterDeserialization() { }
     147    private void AfterDeserialization() {
     148      RegisterEventHandlers();
     149    }
    133150
    134151    public override IDeepCloneable Clone(Cloner cloner) {
    135152      return new NeuralNetworkRegression(this, cloner);
    136153    }
     154
     155    private void HiddenLayersParameterValueChanged(object source, EventArgs e) {
     156      HiddenLayersParameter.Value.ValueChanged += HiddenLayersParameterValueValueChanged;
     157      HiddenLayersParameterValueValueChanged(this, EventArgs.Empty);
     158    }
     159
     160    private void HiddenLayersParameterValueValueChanged(object source, EventArgs e) {
     161      if (HiddenLayers == 0) {
     162        NodesInFirstHiddenLayerParameter.Hidden = true;
     163        NodesInSecondHiddenLayerParameter.Hidden = true;
     164      } else if (HiddenLayers == 1) {
     165        NodesInFirstHiddenLayerParameter.Hidden = false;
     166        NodesInSecondHiddenLayerParameter.Hidden = true;
     167      } else {
     168        NodesInFirstHiddenLayerParameter.Hidden = false;
     169        NodesInSecondHiddenLayerParameter.Hidden = false;
     170      }
     171    }
     172
    137173
    138174    #region neural network
Note: See TracChangeset for help on using the changeset viewer.