Information Technology Reference
In-Depth Information
Note that we are ignoring the second output layer in
the above code.
MakeEnv(); // constructor to set defaults
};
Note that the constructor is just a function (with no
return type and no arguments) that has the same name
as the class type. Also, we have terminated the class
type definition by including the }; at the end.
Now, it is time to define the functions themselves.
Let's start with the constructor:
void MakeEnv::MakePattern(Pattern* pat, \
int idx, int active, int skip) {
int i;
for(i=0;i<active;i++) {
pat.value[skip*idx + i] = 1.0;
}
}
MakeEnv::MakeEnv() {
env = .environments[0];
n_events = 5;
in_active = 5;
out_active = 6;
in_skip = 4;
out_skip = 4;
Finally, we just need to create an instance of the Ma-
keEnv type, and then edit it, and we're done:
MakeEnv make_env;
EditObj(make_env);
Be sure to save the file after you have entered the
above lines of code.
}
Notice that the function definition starts with a scop-
ing operator MakeEnv:: which identifies this as ap-
plying to a function of this particular class type.
Next, we will define the Make function, and its
helpers. Note that in these functions, we are directly
manipulating the Event objects and their constituent
Pattern s, instead of for example writing a text file of
patterns and then reading that in — manipulating these
structures often makes for easier programming.
Then just hit Compile in the script object window.
You should not get any error messages — if you do,
then compare the line(s) in question with those here and
correct any discrepancies (and then hit Compile again
to make the changes take effect). Now, you are ready to
run your new script.
, !
Press the Run button.
You should see an edit dialog appear, with the appro-
priate parameter fields and the Make button across the
bottom. You can click on the field labels, and see the
descriptive comment you entered (and the overall com-
ment at the top of the file appears at the top of the edit
window). This is the same basic technology that is used
throughout the PDP++ system for providing a graphical
interface to the underlying class objects.
void MakeEnv::Make() {
env.events.Reset(); \
// get rid of any existing events
int i;
for(i=0;i<n_events;i++) {
\
// iterate over events
Event* ev = env.events.New(1, Event); \
// create new event
MakeEvent(ev, i);
Hit the Make button on your new edit dialog, and
then click on a few of the new events in the environment
window.
The events should have patterns as you would expect
from the algorithm. You can play with the parameters
and hit Make again to see the effects of the parame-
ters. When you are done, you can go ahead and Run
the training process again with this new environment.
\
// hand off to subroutine
}
env.UpdateAllViews(); \
// update display to reflect changes
}
void MakeEnv::MakeEvent(Event* ev, int idx) {
ev->name = "seq_ev_" + idx; \
// name the event according to index
// first make the input pattern
MakePattern(ev->patterns[0], idx, \
in_active, in_skip);
// then the output pattern
MakePattern(ev->patterns[1], idx, \
out_active, out_skip);
B.5.1
Setting a Stopping Criterion for Training
One thing you might notice with this new environment
is that the network learns all the way to completion
(since the patterns now work better with the limited
}
Search WWH ::




Custom Search