LENS

Programmer's Guide: How To Create Example Loading Commands


If you have created a new type of network, you may need to override the standard functions for loading examples and example events into the network. You do this by defining a new example or event loading function and setting the example set's loadEvent or loadExample function pointer to your new function. The function should be placed in extension.h. You will probably want to define a shell command which will actually set the loadEvent or loadExample pointer to your own function.

Another thing you may want to customize is the order in which examples are selected during training or testing. This is done by creating a new example selection type. Add the new type to the EXAMPLE SELECTION TYPES section of type.h, as in:

    /* DOUG... */
    #define MY_EX_MODE   ((mask) 1 << 12)
    /* ...DOUG */
Now write an example selection command and put it in extension.c. It should be similar to this:
    static flag myLoadNextExample(ExampleSet S) {
      S->currentExampleNum = randInt(S->numExamples);
      return S->loadExample(S->example[S->currentExampleNum]);
    }

Finally, register the example selection type by putting a line like this in userInit() in extension.c:

    registerExampleModeType("MY_EX_MODE", MY_EX_MODE, myLoadNextExample);

Now you can call exampleSetMode with the mode "MY_EX_MODE" and examples will be selected using your function.


Douglas Rohde
Last modified: Mon Nov 13 23:46:15 EST 2000