Report abuse

declare variable

1
2
3
4
5
        private double[][] input;
        private double[][] ideal;
        private BasicNeuralDataSet dataset;
        private BasicNetwork network;

load variable

1
2
3
4
5
6
7
8
        public void LoadNeuralNetwork()
        {
            this.network = new BasicNetwork();
            this.network = LoadNET(networkTextBox.Text) as BasicNetwork;
            this.network.Name = "something";
            this.network.Description = "something else";
        }

load function

1
2
3
4
5
6
7
8
9
        public static object LoadNET(string filename)
        {
            Stream s = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
            BinaryFormatter b = new BinaryFormatter();
            object obj = b.Deserialize(s);
            s.Close(); 
            return obj;
        }

function where I try to use 'this.network'

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
        private void TrainNetworkHybrid()
        {
            if (network != null)
            {
            }
            this.dataset.Description = "not null";
            this.dataset.Name = "something entirely differnt";
            ITrain train = new ResilientPropagation(this.network, this.dataset); 
            //this.network and this.dataset all have no null properties now
            double lastError = Double.MaxValue;
            int epoch = 1;

            do
            {
                train.Iteration(); //NullReferenceException happens here
                double error = train.Error;

                backgroundWorker1.ReportProgress(0, "Iteration(ResProp) #" + epoch + " Error:"
                        + error);

                if (error > 0.05)
                {
                    if (trainAnneal == true)
                    {
                        TrainNetworkAnneal();
                        trainAnneal = false;
                    }
                }

                lastError = error;
                epoch++;
            } while (train.Error > MAX_ERROR && backgroundWorker1.CancellationPending == false && epoch < MAX_ITERATIONS);
        }