// Add a custom layer to the network.
        public static void AddLayer(ref NetworkContainer container, ref EncogLayerSettings settings)
        {
            if (settings.neuronCount <= 0)
            {
                throw new InvalidNeuronCountException("Neuroncount should be higher than 0.");
            }

            try
            {
                container.network.AddLayer(new BasicLayer(
                                               settings.activationFunction,
                                               settings.hasBias,
                                               settings.neuronCount));
            }
            catch
            {
                throw new EncogException("Adding layer failed.");
            }
        }
Example #2
0
        // Prepare network for training, this is mainly setting up the layers and activation functions.
        public static void PrepareNetwork(ref NetworkContainer container, ref ImageNetworkTrainSettings settings)
        {
            if (settings.trainSettings.dataset == null)
            {
                throw new IncorrectActionOrderException("Prepare data before preparing network.");
            }

            EncogWrapper.Instantiate(ref container);

            EncogLayerSettings inputLayerSettings = new EncogLayerSettings
            {
                activationFunction = null,
                hasBias            = true,
                neuronCount        = settings.trainSettings.dataset[0].Length
            };

            EncogWrapper.AddLayer(ref container, ref inputLayerSettings);

            EncogLayerSettings hiddenLayerOneSettings = new EncogLayerSettings
            {
                activationFunction = new ActivationElliott(),
                hasBias            = true,
                neuronCount        = 100
            };

            EncogWrapper.AddLayer(ref container, ref hiddenLayerOneSettings);

            EncogLayerSettings outputLayerSettings = new EncogLayerSettings
            {
                activationFunction = new ActivationElliott(),
                hasBias            = false,
                neuronCount        = 1
            };

            EncogWrapper.AddLayer(ref container, ref outputLayerSettings);
            EncogWrapper.FinalizeNetwork(ref container);
        }