inst4.0		! Feb 7 1989
!****************************************************************
!*								*
!*	"Sample" Back-Propagation Network Builder		*
!*								*
!****************************************************************
!
!	This script builds a back-propagation network designed
!	to solve the exclusive "OR" problem with two inputs.

!	*** Load the Control Strategy and LRS if needed

@LdCS	"backprop"		!control strategy
@LdLR	"backprop"		!L/R schedule

=netn "Sample InstaNet with Instruments"
=DRcF	1			!recall re-display on
=DRcN	1			!show each recall

!	*** Build the Input Layer ***

@LLdf				!load default layer to mi_layer structure
=LDln	"In"			!layer name
=Lpes	2			!2 PEs for XOR
=Ltrn	"Linear"		!buffer
=LDsp	6			!spacing
=x	100			!place to put layer on screen
=y	 80
#Incl	"stdnwgtf.iif"		!standard # weight fields
@LAdd				!add the input layer
=x	130			!position hidden & output over center

!	*** Build the first hidden Layer ***

@LLdf				!start with default layer again
=LDln	"H"			!layer name
=Lpes	1			!One Hidden PE
=Ltrn	"Sigmoid"		!transfer function
=Llrn	"Delta-Rule"		!Generalized Delta learning rule
+y	60			!up higher on display
#Incl	"stdnwgtf.iif"		!standard # weight fields
@LAdd

!	*** Connect Hidden Layer to Bias & Input Layers ***

=SPEl	1			!current layer
@SlPE				!select it as destination (sb already)
=NPEl	-1			!near to bias term (source)
@NrPE
=cnwt	1.0			!connection weight
=cnty	WVar			!variable
=cnsc	WAbs			!absolute
@LCFl				!fully connect to bias element
=NPEl	0			!input layer
@NrPE
@LCFl				!fully connect to input layer

!	*** Build the output layer & connect it to prior, input & bias term ***

@LLdf				!load default layer to mi_layer structure
=LDln	"Out"			!layer name
=Lpes	1			!copy # of input PEs from menu
=Ltrn	"Sigmoid"		!transfer function
=Llrn	"Delta-Rule"		!Generalized Delta learning rule
+y	60
#Incl	"stdnwgtf.iif"		!standard # weight fields
@LAdd				!add the output layer

=SPEl	2			!current layer
@SlPE				!select it as destination (sb already)
=NPEl	-1			!near to bias term (source)
@NrPE
@LCFl				!fully connect to bias element
=NPEl	1			!previous layer
@NrPE
@LCFl				!fully connect to input layer
=NPEl	0			!input layer
@NrPE
@LCFl				!fully connect to input layer

!	*** Select Control Strategy & L/R Schedule ***

=LrnN	4000			!learn counter for LearnN
@LLsl				!load super layer
=Lctl	"backprop"		!backprop control strategy
=Llrs	"backprop"		!backprop L/R Schedule
=Llnn	"sample"		!name of learn input
=Lrcn	"sample"		!name of recall output
=Llio    321			!binary,sequential,load (0x0141)
=Lrio    1137			!binary,seq,inp, des out, header (0x0471)
=Lax1	4			!Set epoch for instruments
=Lscl	 0			!input  low-value
=Loff	 1			!input  high-value
=Llow	 0			!output low-value
=Lhgh	 1			!output high-value
@SVsl				!save it back

!	*** Build Instruments - all use the same probe ***

@ILdD				!load default instrument
=x	200			!place to put instrument on screen
=y	 50
=ITit	"RMS Error"		!Instrument title
=IEpc	1			!RMS over an epoch
=Ihgt	64
=Iwdt	400
=Ivmn	0.0
=Ivmx	1.0
=Ignx	100			!100 graph points
=Inpl	2			!2 plots
=IGC0	11			!Plot colors
=IGC1	13
=IGCF	12			!Foreground color
=IGCB	8			!Background color
=IRcA	0			!Not active in recall
=ILDv	10			!Every 10 iterations
=IPrb	"Output"		!Point to default probe
=ICAc	1			!Convergence criterion active
=ICTh	0.05			!Convergence Threshold
@IAdd				!Now create instrument

@ILdD				!load default instrument
=x	200			!place to put instrument on screen
=y	218
=ITit	"Weight Histogram"	!Instrument title
=IGTy	"Hist"			!Graph type
=IGVr	"Weight"		!Variable
=ITMd	0			!No transformation
=Ihgt	64
=Iwdt	400
=Ivmn	-15.0
=Ivmx	15.0
=Ignx	100			!100 bins
=IGC0	11			!Plot colors
=IGC1	11
=IGCF	12			!Foreground color
=IGCB	8			!Background color
=IRcA	0			!Not active in recall
=ILDv	120			!Every 120 iterations
=IPrb	"Output"		!Point to probe
@IAdd				!Now create instrument

@ILdD				!load default instrument
=x	200			!place to put instrument on screen
=y	124
=ITit	"RMS Weights"		!Instrument title
=IGVr	"Weight"		!Variable
=IEpc	1			!RMS over an epoch
=Ihgt	64
=Iwdt	400
=Ivmn	0.0
=Ivmx	10.0
=Ignx	100			!100 graph points
=Inpl	2			!2 plots
=IGC0	11			!Plot colors
=IGC1	13
=IGCF	12			!Foreground color
=IGCB	8			!Background color
=IRcA	0			!Not active in recall
=ILDv	10			!Every 10 iterations
=IPrb	"Output"		!Point to probe
@IAdd				!Now create instrument

=jogl	-.1			!lower limit for jog
=jogh	+.1			!upper limit for jog
=seed	257			!starting seed number
@seed				!set the seed
@Nrnd				!randomize the network
=DLnF	0			!kill redraw flag durint learning
=DRcF	0			!ditto recall
@EOF
