inst4.0		!01-Jun-89  (bam.ins)  BAM Network Builder
!****************************************************************
!*								*
!*	BAM Network Generator					* 
!*								*
!****************************************************************

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

?&Hd1	1
>bge	CheckOut
@Err	"BAM MUST have at least one hidden 1 PE"
:CheckOut
?&Hd2	1
>bge	OutOK
@Err	"BAM MUST have at least one hidden 2 PE"
:OutOK

!	*** Estimate the layer spacing ***
=f0	6.0
=f1	&Hd1
+f1	&Hd2
/f1	15.0
-f0	f1
?f0	2.0
>bge	SpacOK
=f0	2.0
:SpacOK

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

@LdCS	"bam"			!control strategy
@LdLR	"hopfield"		!L/R schedule
@LdSt	"default"		!Default style

=netn	"InstaNet (tm) BAM Network version 2.00 01-Jun-89"
=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	&Hd1			!Input buffer spans
+Lpes	&Hd2			!BAM1 and BAM2 layers
=Ltrn	"Signum"		!transfer function
=LDsp	f0			!spacing
=x	100			!place to put layer on screen
=y	 60
#Incl	"stdnwgtf.iif"		!standard # weight fields
@LAdd				!add the input layer

!	*** Build the BAM I layer ***

@LLdf				!start with default layer again
=LDln	"BAM I"			!layer name
=Lpes	&Hd1			!desired number of PEs
=Ltrn	"BAM"			!transfer function
=Llrn	"BSB:Hebb"		!learning rule
=LDsp	f0			!spacing
=LInL	0.0			!low initialization limit
=LInH	0.0			!high initialization limit
+y	70			!up higher on display
#Incl	"stdnwgtf.iif"		!standard # weight fields
@LAdd
=n1	LayN			!track BAM I layer

!	*** Connect input layer to BAM I layer ***

=NPEl	0			!input layer
@NrPE
=SPEl	LayN			!current layer
@SlPE
=cnwt	1.0			!connection weight
=cnty	WSet			!set connections to input layer
=cnsc	WRel			!relative connections
@LCCr				!connect corresponding

!	*** Build the BAM II layer ***

=n0	f0			!calculate x offset for layer
*n0	&Hd1
*n0	10			!# pixels per x unit

@LLdf				!start with default layer again
=LDln	"BAM II"		!layer name
=Lpes	&Hd2			!desired number of PEs
=Ltrn	"BAM"			!transfer function
=Llrn	"BSB:Hebb"		!learning rule
=LDsp	f0			!spacing
=LInL	0.0			!low initialization limit
=LInH	0.0			!high initialization limit
+x	n0
+y	70			!up higher on display
#Incl	"stdnwgtf.iif"		!standard # weight fields
@LAdd
=n2	LayN			!track BAM II layer

!	*** Connect input layer to BAM II layer ***

=NPEl	0			!input layer
=NPEn	&Hd1			!Start where BAM I left off
=SPEl	LayN			!current layer
=SPEn	0			!start of layer
:In2Bam2			!now connect 1 by 1
@SlPE				!select next PE in BAM2 layer
@NrPE				!select next PE in input layer
@PCon				!connect two PEs together
+NPEn	1			!next PE in input layer
+SPEn	1			!next PE in BAM II layer
?SPEn	&Hd2			!past the end?
>blt	In2Bam2			!No
=SPEn	0
=NPEn	0

!	*** Build the output layer ***

@LLdf				!load default layer to mi_layer structure
=LDln	"Out"			!layer name
=Lpes	&Hd1			!output buffer spans
+Lpes	&Hd2			!BAM1 and BAM2 layers
=n4	Lpes			!Save #pes in output layer
=Ltrn	"Linear"		!transfer function
=LDsp	f0			!spacing
-x	n0
+y	70
#Incl	"stdnwgtf.iif"		!standard # weight fields
@LAdd				!add the output layer
=n7	LayN			!save for stdprobe

!	*** Connect BAM 1 layer to output layer ***

=SPEl	LayN			!output layer
@SlPE
=NPEl	n1			!BAM I layer
@NrPE
=cnty	WFix
@LCCr

!	*** Connect BAM 2 layer to output layer ***

=NPEl	n2			!BAM II layer
=NPEn	0			!Start of layer
=SPEl	LayN			!Output layer
=SPEn	&Hd1			!Start where BAM I left off
:Bam22Out			!now connect 1 by 1
@SlPE				!select next PE in output layer
@NrPE				!select next PE in BAM II layer
@PCon				!connect two PEs together
+SPEn	1			!next PE in output layer
+NPEn	1			!next PE in BAM II layer
?NPEn	&Hd2			!past the end?
>blt	Bam22Out		!No
=SPEn	0
=NPEn	0

!	*** Connect BAM I & BAM II layers ***

=cnwt	0.0			!zero weights to start
=cnty	WVar			!variable so they can "learn"
=cnsc	WAbs			!Absolute connections
=SPEl	n1			!BAM II -> BAM I
@SlPE
=NPEl	n2
@NrPE
@LCFl
=SPEl	n2			!BAM I -> BAM II
@SlPE
=NPEl	n1
@NrPE
@LCFl

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

@LLsl				!load super layer
=Lctl	"bam"			!control strategy
=Llrs	"hopfield"		!L/R Schedule
=Llnn	"bam"			!name of learn input
=Lrcn	"bam"			!name of recall output
+Lflg	LAAs			!auto-associative network
=Lscl	-1			!input  low-value
=Loff	 1			!input  high-value
=Llow	-1			!output low-value
=Lhgh	 1			!output high-value
@SVsl				!save it back
!
=n5	-1.0
=n6	1.0
#Incl	"stdprobe.iif"		!Standard probe include file
!
@EOF


