havBpNet:J

Intro    Network Classes Overview    Data Classes Overview    Packages

havBpNet:J Home Page

Saving & Restoring instances of havTdata

If, when training our network, we scaled (using havlog) and/or normalized (with M&S), it is important that we retain knowledge of things like the havlog shape and the specific values of mean and std-dev used so that we can use these same values for consultation or continued training with (perhaps) other data. havTdata provides methods for both saving and restoring this information. The mechanism used is similar to those used for saving and restoring network layers.

Saving Scale and Normalization parameter information

The following excerpt illustrates one way of saving this information in the same file used to save a network’s other general information and layers.

NOTE: The order in which information is saved is not really important except that it should be restored in the same order.

 save_file = new FileOutputStream(savefile);  // open the SAVE file
 String myStuff = new String("\n" + bias.getValue());  
 buf = new byte[myStuff.length()];
 myStuff.getBytes(0, myStuff.length(), buf, 0);
 try {
    save_file.write(buf);            // save some private info/data
    train_data.SaveParms(save_file); // save M&S for train data
    net.Save(save_file);             // save the havBpNodeList
    bias.Save(save_file);            // then save each layer in the net
    in.Save(save_file);
    hid.Save(save_file);
    out.Save(save_file);
    save_file.close();
 } catch (IOException e) {
    System.out.println("I/O Error : " + e.toString());
 } 

Notice that, even though we have both training and test data-sets in use, there is no need to save them both because the important parameters were calculated for the training set and copied over to the test set.

Notice that the save operation saves parameter information for both input-pattern and expected-pattern parts. This parameter information will be needed for consultation, even if no expected data is read into the data-set, so that appropriate de-normalization can be performed on the network’s responses to consultations.

Restoring Scale and Normalization parameter information

When we restore a network for consultation or for additional training, it is important to use the same scaling and normalization parameters than were used in training. havTdata provides mechanisms for this purpose. In the following excerpt, we will restore a saved network. We will also restore scaling and normalization parameters and use these to scale and normalize our consultation data. It should be noted that the example above assumes that the train_data and test_data data-sets have already been created as illustrated in an earlier example.


    net_file = new FileInputStream(netfile);   // open the SAVE file
    biasValue = havSys.readDouble(net_file);   // first restore the private information

    train_data.RestoreParms(netfile); // Restore mean & stdev values for previous training data
    test_data.CopyParms(train_data);  // copy mean & stdev values to test data set

    havBpNodeList net = new havBpNodeList(net_file);   // followed by the nodelist and
    havBpLayer bias   = new havBpLayer(net, net_file); // then restore the network layers
    havBpLayer in     = new havBpLayer(net, net_file); // using the same order in which they
    havBpLayer hid    = new havBpLayer(net, net_file); // were saved
    havBpLayer out    = new havBpLayer(net, net_file);
    net_file.close();
 

When train_data is restored above, the following scaling and normalization information is read in from the save-file:

It might be obvious, but for clarity it should be noted that no information about Vector normalization is either saved or restored. Future revisions of these data handling classes may add an indicator for Vector normalization but for now, you must remember to apply Vector normalization if it was used during training.



Data Overview || Data Create || Data Scaling || Data Performance
Data Save & Restore || Data Presentation Order

Intro    Network Classes Overview    Data Classes Overview    Packages

Copyright © 1998 by hav.Software. All Rights Reserved.