| California Scientific BrainMaker Neural Network Software | ||||||
| Home | Applications | What Are Neural Networks | Products | Ordering Info | Tech Support | |
Calling BrainMaker from another programBrainMaker can be called from another program - this is how we make GTO work. Although we use this feature ourselves, we do not support its use by our customers. Calling one program from another is a very advanced programming technique. In order to even think about doing this, you should already have built several Windows applications. If you try this and have trouble, don't bother calling us, we're not going to help you. This is all the help you're going to get, right here. Under Windows, you don't use spawn, you use WinExec. Processing is not sequential as it is under DOS (i.e. whereas under DOS, the spawn command can be called such that it only returns when the other program has finished executing, under Windows the WinExec command returns immediately and both programs execute simultaneously) so that if you need to know when BrainMaker has finished, you must set up a callback. In the following example, when BrainMaker has finished training, it sends the WM_COMMAND message to the calling window, with WPARAM set to the value set by the calling program (212 in the first example) and LPARAM set to Brainmaker's return code. These are routines that call Brainmaker to train and test
static trainBrainMaker( char far *netfile ) {
char commandLine[256];
sprintf( commandLine, "\'%Fs\' -Train %ld", netfile, MaxRuns );
SetupInstanceCallback( commandLine, 212 );
return YES;
}
static testBrainMaker( char far *netfile ) {
char commandLine[256];
sprintf( commandLine, "\'%Fs\' -test", netfile );
SetupInstanceCallback( commandLine, 212 );
return YES;
}
int SetupInstanceCallback( char *commandLine, int callbackWParam ) {
char appendedLine[300];
sprintf( appendedLine, "BRAINMAK.EXE -@ %ld %d %s",
(long)hWnd, callbackWParam, commandLine );
WinExec( appendedLine, SW_SHOWMINNOACTIVE );
brainMakerSessionIsActive = YES;
}
This is the command-line processing inside Brainmaker
static int batchMode(
char far *commandline, char far *factfile,
int nCmdShow, int *numberOfExtraFieldsToSkip ) {
if( *commandline != '-' ) return NO;
SessionIsBatchMode = YES;
if( *factfile <= ' ' ) factfile = NULL;
switch( commandline[1] ) {
#ifdef PROFESSIONAL
case 'a':
case 'A': // analyze sensitivity on a file
setupBatch( Net.factfilename, factfile, nCmdShow );
newExt( Net.plotFile.filename, Net.netfilename, Extensions[12] );
MenuSetState( 225, BrainMakerState = Analyzing );
FileSensitivity( 1, YES ); return YES;
#endif
case 'b': // batch, inputs
case 'B': // batch, no inputs
setupBatch( Net.runfilename, factfile, nCmdShow );
if( Net.outputFile.fp == NULL ) {
openBatchRunOutputFile( commandline[1] == 'b' );
}
RunNet();
return YES;
case 'c':
case 'C': // read configuration file filename.cfg
commandline += findWord( commandline );
commandline += skipBlanks( commandline );
wordcopy( myFN, commandline );
ReadConfigurationFile( StripQuotes(myFN) );
return NO;
#ifdef PROFESSIONAL
case 'g':
case 'G': // make graph file <factnumber> <neuron>
setupBatch( Net.factfilename, factfile, nCmdShow );
setupPlotFile( &Net.plotFile, commandline );
Write_Plot_File( &Net.plotFile, YES ); return YES;
case 'n':
case 'N': // add noise to connections <noiseval>
setupBatch( NULL, NULL, nCmdShow );
commandline += findWord( commandline );
commandline += skipBlanks( commandline );
ParseNumber( commandline, &LParam.NoiseBandwidth );
NoisyNet(); return writeBatchNet( Net.netfilename );
case 'p': // prune, no lock <layer> <prunevalue>
case 'P': // prune, lock <layer> <prunevalue>
setupBatch( NULL, NULL, nCmdShow );
performPrune( commandline, commandline[1] == 'P' );
return writeBatchNet( Net.netfilename );
case 'r':
case 'R': // report file on a neuron <factnumber> <neuron>
setupBatch( Net.factfilename, factfile, nCmdShow );
setupPlotFile( &Net.plotFile, commandline ); // kludge
newExt( Net.plotFile.filename, Net.netfilename, Extensions[10] );
WriteNeuronSensitivityReport( Net.plotFile.filename, YES );
return YES;
case 's':
case 'S': // change size of network <layer> <neurons>
setupBatch( NULL, NULL, nCmdShow );
performResize( commandline );
return writeBatchNet( Net.netfilename );
case 't': // test
if( commandline[2] != 'r' ) {
setupBatch( Net.testfilename, factfile, nCmdShow );
MenuSetState( 113, BrainMakerState = Testing );
TestNet();
return YES;
} // else fall through and train
case 'T': // train <maxruns>
MenuSetCheck( 123, Net.DisplayOn = NO );
setupBatch( Net.factfilename, factfile, nCmdShow );
setupTraining( commandline );
MenuSetState( 112, BrainMakerState = Training );
TrainNet();
if( OperationInProgress() && TStat.StatFileEnabled ) {
MenuSetState( 113, BrainMakerState = Testing );
TStat.RunNumber = LStat.RunNumber;
TestNet();
}
return writeBatchNet( Net.netfilename );
#endif
case 'x':
case 'X': // exit mode
setExitMode( commandline + 2 );
return NO;
case 'y':
case 'Y': // exit argument
setExitArgument( commandline + 2 );
return NO;
case '@': // window of calling process, callback, index
setupInformWhenExiting( commandline );
*numberOfExtraFieldsToSkip = 2;
return NO;
}
}
This is what BrainMaker does when it exits
if( informWhenExiting ) {
PostMessage( windowToInformWhenExiting, WM_COMMAND,
commandToSendWhenExiting, (LPARAM)exitValue );
}
|
| Home | Applications | What Are Neural Networks | Products | Ordering Info | Tech Support | |
| California Scientific BrainMaker Neural Network Software | ||||||