This page is a listing of the entire contents of this library for IDL. This listing is the long version. Viewing the much more compact listing may be handier.
*NAME: NNET.PRO *PURPOSE: Neural network classifier. This is a standard 3-layer back-propagation net. *CALLING SEQUENCE: NNET, bias_hid, w_hid, bias_out, w_out, input, h_output, $ output, first, second, third *INPUTS: bias_hid - Bias weights on the hidden neurons (DP vector [n_hid]). w_hid - weights between input & hidden layers (DP array [n_in,n_hid]). bias_out - Bias weights on the output neurons (DP vector [n_out]). w_out - weights between hidden & output layers (DP array [n_hid,n_out]). input - input values (DP vector [n_in]). *OUTPUTS: h_output - computed values of hidden layer neurons (DP vector [n_hid]). output - computed values of output neurons (DP vector [n_out]). first - index of output neuron with highest value. second - index of second place neuron. third - index of third place neuron (if there are more than two output neurons). *KEYWORD PARAMETERS None. *EXAMPLE: IDL> nnet, bias_hid, w_hid, bias_out, w_out, input, hout, output - input is the pattern you want to classify. Must be a normalized float or DP vector or the same size as the training patterns used to train the weights. *HISTORY: Version 1.0 T. Beck Advanced Computer Concepts, Inc. 21 Apr 1999
(See /host/bluemoon/usr2/idllib/astron/contrib/beck/nnet.pro)
*NAME:
NNET_READ_WEIGHTS.PRO
*PURPOSE:
Reads computed weights for a Neural Network from FITS file created
by NNET_WRITE_WEIGHTS.PRO
*CATEGORY:
Misc.
*CALLING SEQUENCE:
NNET_READ_WEIGHTS, Filename, Bias_hid, W_hid, Bias_out, W_out
*INPUTS:
Filename - Name of FITS file to be read.
*OUTPUTS:
Bias_hid - bias weights on the hidden neurons.
W_hid - weights between input & hidden layers.
Bias_out - bias weights on the output neurons.
W_out - weights between hidden & output layers.
*KEYWORD PARAMETERS:
None.
*NOTES:
*EXAMPLES:
IDL> nnet_read_weights, 'wts.fits', bhid, whid, bout, wout
*HISTORY:
Version 1.0 Terry Beck
Advanced Computer Concepts, Inc. 21 Apr 1999
(See /host/bluemoon/usr2/idllib/astron/contrib/beck/nnet_read_weights.pro)
*NAME:
NNET_WRITE_WEIGHTS.PRO
*PURPOSE:
Writes computed weights for a Neural Network to a FITS file.
*CATEGORY:
Misc.
*CALLING SEQUENCE:
NNET_WRITE_WEIGHTS, Bias_hid, B_hid, Bias_out, B_out
*INPUTS:
Bias_hid - bias weights on the hidden neurons.
W_hid - weights between input & hidden layers.
Bias_out - bias weights on the output neurons.
W_out - weights between hidden & output layers.
*OUTPUTS:
Program creates a FITS file.
*KEYWORD PARAMETERS:
outfile - name of output FITS file, default="weights.fits"
*NOTES:
*EXAMPLES:
IDL> nnet_write_weights, bhid, whid, bout, wout, outfile='wts.fits'
*HISTORY:
Version 1.0 Terry Beck
Advanced Computer Concepts, Inc. 21 Apr 1999
(See /host/bluemoon/usr2/idllib/astron/contrib/beck/nnet_write_weights.pro)
*NAME:
TRAIN_NNET.PRO
*PURPOSE:
Trains (computes) the values of the weights used by the neural-network
classifier.
*CALLING SEQUENCE:
TRAIN_NNET, n_pat, n_in, n_hid, n_out, train_set, classes, bias_hid, $
w_hid, bias_out, w_out
*INPUTS:
n_pat - number of training patterns (INT scalar).
n_in - number of input neurons (INT scalar).
n_hid - number of hidden neurons (INT scalar).
n_out - number of output neurons (INT scalar).
train_set - training data ( DBLARR[n_in,n_pat] ).
classes - classification of each training pattern ( INTARR[n_pat] ).
*OUTPUTS:
bias_hid - bias weights on the hidden neurons ( DBLARR[n_hid] ).
w_hid - weights between input & hidden layers ( DBLARR[n_in,n_hid] ).
bias_out - bias weights on the output neurons ( DBLARR[n_out] ).
w_out - weights between hidden & output layers ( DBLARR[n_hid,n_out] ).
*KEYWORD PARAMETERS:
outfile - set this keyword to write the computed weights to a FITS
file.
alpha - learning rate, default=0.15.
mu - momemtum term, default=0.10.
*EXAMPLE:
This example uses the neural network as a stellar spectral classifier.
It could be used to classify any type of data, if the data could
be input as a normalized vector.
--------------------------------------------------------------------
You have a set of 10 flux & wavelength calibrated spectra. If
necessary, resample the spectra to the same dispersion (eg. nm/pixel).
Extract the same wavelength region from all spectra. Normalize. Make
sure all pixel values are between 0 and 1.0. Stack all spectra into
a single 2-D array. This is the training set (see input variable
"train_set" above). If each spectrum has 200 pixels, then the size of
train_set will be (200,10). n_pat = 10 and n_in = 200 also.
Create a integer vector ("classes", above) of 10 elements, each
element is a number that designates the spectral type of the
corresponding spectra in the training set, by subscript:
classes(0) <====> train_set(*,0)
It is help to generate a lookup table:
class SP type
----- -------
0 M0V
1 M1V
2 M1.5V
3 M2V
4 M3V
5 M4V
6 M5V
Example of classes vector:
IDL> classes = [0,1,2,2,3,4,4,5,6,6]
Note that in this case some spectral types have more than one example.
It is a good idea to have a many examples of each spectral type as
possible, this will allow the neural net to generalize better and be
able to ignore noise.
CAUTION: Two examples of the same spectal type that very different
in appearance due to noise, poor calibraion, etc. may cause the
network not to converge to a solution.
In this example the number of output neurons (n_out) is equal to 7.
Set n_hid to some number between n_in and n_out, in this example,
100 would be a good choice.
Ready to run:
IDL> train_nnet, 10, 200, 100, 7, train_set, classes, $
bias_hid, w_hid, bias_out, w_out
*OPERATIONAL NOTES:
While program is running, it prints the training epoch (iteration)
and the total error of all training patterns across all output units
to standard output.
*HISTORY:
Version 1.0 Terry Beck
Advanced Computer Concepts, Inc. 21 Apr 1999
(See /host/bluemoon/usr2/idllib/astron/contrib/beck/train_nnet.pro)