public NetworkState(RecurrentNetwork network, NetworkState last) { this.Network = network; states = new List <object>(); double[] input = new double[network.Layers[0].InputSize]; this.Input = input; double[] output = null; for (int i = 0; i < network.Layers.Count; i++) { Layer layer = network.Layers[i]; output = new double[layer.Size]; if (layer is RecurrentLayer) { RecurrentState lastState = last != null ? (RecurrentState)last.states[i] : null; states.Add(new RecurrentState(input, output, lastState)); } else { states.Add(new FeedForwardState(input, output)); } // The input of the next layer is the output of the last. input = output; } this.Output = output; }
public NetworkTrainingState(RecurrentNetwork network) { Network = network; double[] inputErrors = new double[network.Layers[0].InputSize]; double[] errors = null; states = new List <TrainingState>(); for (int i = 0; i < network.Layers.Count; i++) { Layer layer = network.Layers[i]; errors = new double[layer.Size]; if (layer is RecurrentLayer) { //RecurrentState lastState = last != null ? (RecurrentState)last.states[i] : null; states.Add(new RecurrentTrainingState(inputErrors, errors)); } else { states.Add(new FeedForwardTrainingState(inputErrors, errors)); } // The input errors next layer are the errors of the last. inputErrors = errors; } this.Errors = errors; }
public NetworkState(RecurrentNetwork network) : this(network, null) { }
public RecurrentNetworkTrainer(RecurrentNetwork network) { this.Network = network; this.trainingState = new NetworkTrainingState(network); }