public class EpochTrainerEx1 extends Object implements Serializable
Trains a 2-layer network using the 2-stage Epoch trainer.
This example trains a 2-layer network using 100 training patterns from one nominal and one continuous input attribute. The nominal attribute has three classes which are encoded using binary encoding. This results in three binary network input columns. The continuous input attribute is scaled to fall in the interval [0,1].
The network training targets were generated using the relationship: $$y = 10X_1 + 20X_2 + 30X_3 + 2.0X_4$$ where
\(X_1, X_2, X_3\) are the three binary columns, corresponding to categories 1-3 of the nominal attribute, and \(X_4\) is the scaled continuous attribute.
The structure of the network consists of four input nodes and two layers, with three perceptrons in the hidden layer and one in the output layer. The following figure illustrates this structure:
With 4 inputs, 3 perceptrons in the hidden layer, and one output perceptron, there are a total of 19 weights in this network (4x3+3x1+3+1). The activation functions are all linear. Since the target output is a linear function of the input attributes, linear activation functions guarantee that the network fitted values will exactly match their targets. Of course, this same result could have been obtained using linear multiple regression.
Training is conducted using a two-stage Epoch trainer. The trainer for Stage I is set to the Least Squares Trainer. The number of epochs is set to 10 and the epoch size (number of randomly selected observations for each epoch) is set to 20. Stage II training is conducted using the quasi-Newton trainer. Stage II training is always conducted using all training patterns. Stage II training is optional.
Constructor and Description |
---|
EpochTrainerEx1() |
Modifier and Type | Method and Description |
---|---|
static void |
main(String[] args) |
static void |
write(Object obj,
String filename) |
public static void write(Object obj, String filename) throws IOException
IOException
Copyright © 2020 Rogue Wave Software. All rights reserved.