Exemplo n.º 1
0
    public void SetActivationFunction(NeuralActivationFunction _neuralActivationFunction)
    {
        switch (_neuralActivationFunction)
        {
        case NeuralActivationFunction.Sigmoid:
            actFunction    = ActivationFunctions.Sigmoid;
            actFunctionDer = ActivationFunctions.SigmoidDer;
            break;

        case NeuralActivationFunction.Tanh:
            actFunction    = ActivationFunctions.Tanh;
            actFunctionDer = ActivationFunctions.TanhDer;
            break;

        case NeuralActivationFunction.Relu:
            actFunction    = ActivationFunctions.Relu;
            actFunctionDer = ActivationFunctions.ReluDer;
            break;

        case NeuralActivationFunction.LeakyRelu:
            actFunction    = ActivationFunctions.LeakyRelu;
            actFunctionDer = ActivationFunctions.LeakyReluDer;
            break;

        default:
            break;
        }
    }
Exemplo n.º 2
0
 public Neuron(NeuralActivationFunction _neuralActivationFunction)
 {
     inputSynapses  = new List <Synapse>();
     outputSynapses = new List <Synapse>();
     SetActivationFunction(_neuralActivationFunction);
     bias = NeuralNetwork.GetRandom();
 }
Exemplo n.º 3
0
 public NeuralGeneNode(NeuralActivationFunction _neuralActivationFunction, int _nodeNumber, NeuralNodeType _nodeType)
 {
     inputSynapses  = new List <NeuralGeneConnection>();
     outputSynapses = new List <NeuralGeneConnection>();
     SetActivationFunction(_neuralActivationFunction);
     nodeNumber = _nodeNumber;
     nodeType   = _nodeType;
     bias       = NeatNeuralNetwork.GetRandom();
 }
Exemplo n.º 4
0
    public Neuron(NeuralActivationFunction _neuralActivationFunction, IEnumerable <Neuron> _inputNeurons)
    {
        inputSynapses  = new List <Synapse>();
        outputSynapses = new List <Synapse>();
        SetActivationFunction(_neuralActivationFunction);
        bias = NeuralNetwork.GetRandom();

        foreach (var inputNeuron in _inputNeurons)
        {
            var synapse = new Synapse(inputNeuron, this);
            inputNeuron.outputSynapses.Add(synapse);
            inputSynapses.Add(synapse);
        }
    }
Exemplo n.º 5
0
    public NeuralGeneNode AddHiddenNode(NeuralActivationFunction _neuralActivationFunctions)
    {
        if (HiddenLayers == null)
        {
            HiddenLayers = new List <NeuralGeneNode>();
        }
        if (nodes == null)
        {
            nodes = new List <NeuralGeneNode>();
        }
        NeuralGeneNode tmpNode = new NeuralGeneNode(_neuralActivationFunctions, nodes.Count + 1, NeuralNodeType.Hidden);

        HiddenLayers.Add(tmpNode);
        nodes.Add(tmpNode);
        return(tmpNode);
    }
Exemplo n.º 6
0
    public NeuralGeneNode AddOutputNode(NeuralActivationFunction _neuralActivationFunctions)
    {
        if (OutputLayer == null)
        {
            OutputLayer = new List <NeuralGeneNode>();
        }
        if (nodes == null)
        {
            nodes = new List <NeuralGeneNode>();
        }
        NeuralGeneNode tmpNode = new NeuralGeneNode(_neuralActivationFunctions, nodes.Count + 1, NeuralNodeType.Output);

        OutputLayer.Add(tmpNode);
        nodes.Add(tmpNode);
        return(tmpNode);
    }
Exemplo n.º 7
0
 public void AddInputsNode(int _inputSize, NeuralActivationFunction _neuralActivationFunctions)
 {
     if (InputLayer == null)
     {
         InputLayer = new List <NeuralGeneNode>();
     }
     if (nodes == null)
     {
         nodes = new List <NeuralGeneNode>();
     }
     for (int i = 0; i < _inputSize; i++)
     {
         NeuralGeneNode tmpNode = new NeuralGeneNode(_neuralActivationFunctions, i + 1, NeuralNodeType.Input);
         InputLayer.Add(tmpNode);
         nodes.Add(tmpNode);
     }
 }
Exemplo n.º 8
0
 public void AddOutputsNode(int _outputSize, NeuralActivationFunction _neuralActivationFunctions)
 {
     if (OutputLayer == null)
     {
         OutputLayer = new List <NeuralGeneNode>();
     }
     if (nodes == null)
     {
         nodes = new List <NeuralGeneNode>();
     }
     for (int i = 0; i < _outputSize; i++)
     {
         NeuralGeneNode tmpNode = new NeuralGeneNode(_neuralActivationFunctions, nodes.Count + 1, NeuralNodeType.Output);
         OutputLayer.Add(tmpNode);
         nodes.Add(tmpNode);
     }
 }