inst4.0	!  (Cascade.ins)  Casade Correlation w Cumulative Back-Propagation
!************************************************************************
!*							                *
!*	Cascade-Correlation w Cum Back-Propagation Network Builder	*
!*							                *
!************************************************************************ 
!
!	Set counter "Aux 1" in the super layer to the number of
!	iterations between updating weights with the accumulated
!	deltas.

!	*** check that input / output PE count is non-zero

?&In	1
>bge	InOK
@Err	"Cascade-Correlation MUST have at least one input PE"
:InOK
?&Hd1	1
>bge	Hid1OK
@Err	"Cascade-Correlation MUST have at least one Hidden layer"
:Hid1OK
?&Out	1
>bge	OutOK
@Err	"Cascade-Correlation MUST have at least one output PE"
:OutOK

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

@LdCS	"backprop"		!control strategy
@LdLR	"backprop"		!L/R schedule
@LdLR	"cascade"		!Hidden layer LRS

=netn "InstaNet (tm) Cascade-Correlation w Cumulative Back-Propagation Network
=DLnF	0			!learn  re-display off
=DRcF	0			!recall re-display off

!	*** Build the Input Layer ***

@LLdf				!load default layer to mi_layer structure
=LDln	"In"			!layer name
=Lpes	&In			!copy # of input PEs from menu
=x	100			!place to put layer on screen
=y	 80
#Incl	"stdnwgtf.iif"		!standard # weight fields
@LAdd				!add the input layer

!	*** Build the Hidden Layer ***

@LLdf				!start with default layer again
=LDln	"Cascade"		!layer name
=Llrs	"cascade"		!learning recall schedule
=Lpes	&Hd1			!Proper number of PEs
=Lsum	"cascade"		!cascade sum function
=Ltrn	"TanH"			!transfer function
=Llrn	"Norm-Cum-Delta"	!Generalized Delta learning rule
=Lnse	"--None--"		!no noise function
+x	150			!to right on display
+y	100			!up higher on display
#Incl	"stdnwgtf.iif"		!standard # weight fields
@LAdd

!	*** Connect Hidden Layer to Bias 

=SPEl	LayN			!Hidden layer 1
@SlPE				!select it as destination (sb already)
=NPEl	-1			!near to bias term (source)
@NrPE
=cnwt	0.0			!connection weight = 0.0
=cnty	WFix			!fixed
=cnsc	WAbs			!absolute
@LCFl				!fully connect to bias element

!	*** Connect to Input Layer ***

=NPEl	0			!input layer
@NrPE
@LCFl				!fully connect to input layer

!	*** Self Connect in Cascade fashion ***

=SPEl	LayN			!select layer is self
=SPEn	1			!start with PE 1
=NPEl	LayN			!near layer is self
=cnty	WVar			!variable
:OutLp
@SlPE				!select PE
=NPEn	0			!start with PE 0
:InLp
@NrPE				!select PE
@PCon				!connect PE
+NPEn	1			!advance Near PE
?NPEn	SPEn			!compare to Select PE
>blt	InLp			!next near
+SPEn	1			!advance Select PE
?SPEn	&Hd1			!compare to number of hidden PEs
>ble	OutLp			!next select

=n1	LayN			!save Hidden layer 1 for later

!	*** Build the output layer  ***

@LLdf				!load default layer to mi_layer structure
=LDln	"Output"		!layer name
=Lpes	&Out			!copy # of input PEs from menu
=Llrs	"backprop"		!backprop L/R Schedule
=Lsum	"Cascade"		!cascade sum function
=Ltrn	"TanH"			!transfer function
=Llrn	"Norm-Cum-Delta"	!Generalized Delta learning rule
=Lnse	"--None--"		!no noise function
=x	100
+y	100
#Incl	"stdnwgtf.iif"		!standard # weight fields
@LAdd				!add the lower output layer
=n7	LayN			!save for stdprobe

!	*** Connect the output layer to input & Hidden layers  & bias term ***

=SPEl	LayN			!destination is output layer
=SPEn	0
@SlPE				!select destination pe
=cnty	WVar			!connection type is variable

=NPEl	-1			!near to bias term (source)
=NPEn	0
@NrPE
@LCFl				!fully connect

=NPEl	0			!near to input layer
@NrPE
@LCFl				!connect fully

=cnty	WFix			!connection type is fixed initially
=cnwt	0.0			!connection weight 0.0 - no impact
=NPEl	n1			!near to hidden layer
@NrPE
@LCFl

=n0	LayN			!save lower output layer for later

!	***          Add an Output Instrument      ***

!+x	100			!to right on display
!@ILdD				!load default instrument
!=ITit	"Output Error"		!Instrument Title
!=Ihgt	150			!Instrument Height
!=Ignx	32			!Number in x direction
!=Ivmx	2.			!Maximum value
!=ILDv	31			!Instrument Learn
!@IAdd				!Add the instrument

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

@LLsl				!load super layer
=LDnd	3			!Force network display
=Lctl	"backprop"		!backprop control strategy
=Llrs	"backprop"		!backprop L/R Schedule
=Llnn	"4bit"			!name of learn input
=Lrcn	"4bit"			!name of recall output
#Incl	"stdioset.iif"		!standard I/O settings
=Lax1	 16			!nominal number of accumulations
=Lscl	 -1 			!input  low-value
=Loff	 1			!input  high-value
=Llow	 -.8			!output low-value
=Lhgh	 .8			!output high-value
@SVsl				!save the super layer back
!
=n5	-1.0
=n6	1.0
=n4	&Out
#Incl	"stdprobe.iif"		!Standard probe include file
!
=jogl	-.1			!lower limit for jog
=jogh	+.1			!upper limit for jog
=seed	257			!starting seed number
@seed				!set the seed
@Nini				!Initialize the network
@EOF
