#!xerion
############################################################
# builds an 8-?-8 encoder network, by prompting for the
# value of NUMHIDDEN for the number of hidden units.
# It reads "encoder.in".
# '$Id: buildEncoder,v 1.1 93/04/14 11:22:28 drew Exp $'
############################################################
# we need to unset this for some of our tests
unset unset-error

############################################################
# create NUMHIDDEN if it doesn't exist, and set it to a 
# default value (3)
############################################################
if same "$NUMHIDDEN" "" ; then
    var int NUMHIDDEN
    set NUMHIDDEN = 3
fi

############################################################
# if no command args, prompt for a value for NUMHIDDEN
############################################################
if same "$tokc" "1" ; then
    prompt NUMHIDDEN "How many hidden units? ($NUMHIDDEN) "
############################################################
# if one command argument, set NUMHIDDEN to it
############################################################
elif same "$tokc" "2" ; then
    set NUMHIDDEN="${tokv[1]}"
############################################################
# anything else is an error
############################################################
else
    echo "usage: ${tokv[0]} [numHidden]"
    exit
fi

############################################################
# make sure NUMHIDDEN is greater than 0
############################################################
if same $(calc "$NUMHIDDEN <= 0") 1 ; then
    echo "Must have more than 0 hidden units (you tried $NUMHIDDEN)"
    exit
fi

############################################################
# Now actually build the net
############################################################
read encoder.in
