havBpNet:J

Intro    Network Classes Overview    Data Classes Overview    Packages

havBpNet:J Home Page

Saving a Trained Network

Once a network is sufficiently trained, we must save it for use by our consultation programs. In havBpNet, the user is required to explicitly save the nodelist and the layers of the trained network. These save operations are accomplished as follows:


 save_file = new FileOutputStream(savefile);           // open the SAVE  file

 String myStuff = new String("\n" + bias.getValue());  // prepare some private  info/data
 buf = new byte[myStuff.length()];
 myStuff.getBytes(0, myStuff.length(), buf, 0);

 try {
    save_file.write(buf);       // save some private  info/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());
 }

First, we open the file into which the network will be saved.

Since havBpNet uses the standard file system for saving a network, user applications are free to save any other application-specific information that seems appropriate in the save. On the other hand, users might choose to save application-specific information in another file since, when the network is restored, explicit effort will be required to appropriately handle (perhaps skip) this additional data. In the example shown above, we have saved the value of the bias layer’s node. We can later restore this value to ensure that we use the same value for consultation or further training.

Nodelists and layers are saved by sending the Save(...) message to class instances. As shown in the example above, the only argument to the Save(...) method is the file-pointer of the opened save file. It is the user’s responsibility to ensure that the file pointer is appropriately positioned in the save file when telling a nodelist or layer to save itself. It is also the user’s responsibility to close the save file when the network and all application-specific data has been saved.

When saving a layer, the layer’s nodes are automatically saved as well.

The order in which the nodelist and layers are saved is important for several reasons. First, the nodelist to which a layer belongs must exist and be restored before the layer is restored. Second, it is most easy to restore layers in the same order in which they are saved. If this is not done, then the user must exercise great care and needless energy to ensure that the save file’s file-pointer is correctly positioned for restore operations.



Overview || Create || Train || Save || Restore || Consult || Data Scaling

Intro    Network Classes Overview    Data Classes Overview    Packages

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