/// <summary> /// Create a feedforward freeform neural network. /// </summary> /// <param name="input">The input count.</param> /// <param name="hidden1">The first hidden layer count, zero if none.</param> /// <param name="hidden2">The second hidden layer count, zero if none.</param> /// <param name="output">The output count.</param> /// <param name="af">The activation function.</param> /// <returns>The newly crated network.</returns> public static FreeformNetwork CreateFeedforward(int input, int hidden1, int hidden2, int output, IActivationFunction af) { var network = new FreeformNetwork(); IFreeformLayer lastLayer = network.CreateInputLayer(input); IFreeformLayer currentLayer; if (hidden1 > 0) { currentLayer = network.CreateLayer(hidden1); network.ConnectLayers(lastLayer, currentLayer, af, 1.0, false); lastLayer = currentLayer; } if (hidden2 > 0) { currentLayer = network.CreateLayer(hidden2); network.ConnectLayers(lastLayer, currentLayer, af, 1.0, false); lastLayer = currentLayer; } currentLayer = network.CreateOutputLayer(output); network.ConnectLayers(lastLayer, currentLayer, af, 1.0, false); network.Reset(); return(network); }
/// <summary> /// Construct an Elmann recurrent neural network. /// </summary> /// <param name="input">The input count.</param> /// <param name="hidden1">The hidden count.</param> /// <param name="output">The output count.</param> /// <param name="af">The activation function.</param> /// <returns>The newly created network.</returns> public static FreeformNetwork CreateElman(int input, int hidden1, int output, IActivationFunction af) { var network = new FreeformNetwork(); IFreeformLayer inputLayer = network.CreateInputLayer(input); IFreeformLayer hiddenLayer1 = network.CreateLayer(hidden1); IFreeformLayer outputLayer = network.CreateOutputLayer(output); network.ConnectLayers(inputLayer, hiddenLayer1, af, 1.0, false); network.ConnectLayers(hiddenLayer1, outputLayer, af, 1.0, false); network.CreateContext(hiddenLayer1, hiddenLayer1); network.Reset(); return(network); }
public void Execute(IExampleInterface app) { // create a neural network, without using a factory var network = new FreeformNetwork(); IFreeformLayer inputLayer = network.CreateInputLayer(2); IFreeformLayer hiddenLayer1 = network.CreateLayer(3); IFreeformLayer outputLayer = network.CreateOutputLayer(1); network.ConnectLayers(inputLayer, hiddenLayer1, new ActivationSigmoid(), 1.0, false); network.ConnectLayers(hiddenLayer1, outputLayer, new ActivationSigmoid(), 1.0, false); network.Reset(); // create training data IMLDataSet trainingSet = new BasicMLDataSet(XORInput, XORIdeal); EncogUtility.TrainToError(network, trainingSet, 0.01); EncogUtility.Evaluate(network, trainingSet); EncogFramework.Instance.Shutdown(); }
/// <summary> /// Create a feedforward freeform neural network. /// </summary> /// <param name="input">The input count.</param> /// <param name="hidden1">The first hidden layer count, zero if none.</param> /// <param name="hidden2">The second hidden layer count, zero if none.</param> /// <param name="output">The output count.</param> /// <param name="af">The activation function.</param> /// <returns>The newly crated network.</returns> public static FreeformNetwork CreateFeedforward(int input, int hidden1, int hidden2, int output, IActivationFunction af) { var network = new FreeformNetwork(); IFreeformLayer lastLayer = network.CreateInputLayer(input); IFreeformLayer currentLayer; if (hidden1 > 0) { currentLayer = network.CreateLayer(hidden1); network.ConnectLayers(lastLayer, currentLayer, af, 1.0, false); lastLayer = currentLayer; } if (hidden2 > 0) { currentLayer = network.CreateLayer(hidden2); network.ConnectLayers(lastLayer, currentLayer, af, 1.0, false); lastLayer = currentLayer; } currentLayer = network.CreateOutputLayer(output); network.ConnectLayers(lastLayer, currentLayer, af, 1.0, false); network.Reset(); return network; }
/// <summary> /// Construct an Elmann recurrent neural network. /// </summary> /// <param name="input">The input count.</param> /// <param name="hidden1">The hidden count.</param> /// <param name="output">The output count.</param> /// <param name="af">The activation function.</param> /// <returns>The newly created network.</returns> public static FreeformNetwork CreateElman(int input, int hidden1, int output, IActivationFunction af) { var network = new FreeformNetwork(); IFreeformLayer inputLayer = network.CreateInputLayer(input); IFreeformLayer hiddenLayer1 = network.CreateLayer(hidden1); IFreeformLayer outputLayer = network.CreateOutputLayer(output); network.ConnectLayers(inputLayer, hiddenLayer1, af, 1.0, false); network.ConnectLayers(hiddenLayer1, outputLayer, af, 1.0, false); network.CreateContext(hiddenLayer1, hiddenLayer1); network.Reset(); return network; }