Beispiel #1
0
 public Layer(
     Node[] nodes,
     Layer[] previousLayers,
     ActivationFunctionType activationFunctionType         = ActivationFunctionType.RELU,
     InitialisationFunctionType initialisationFunctionType = InitialisationFunctionType.HeEtAl)
 {
     Nodes                      = nodes;
     PreviousLayers             = previousLayers;
     ActivationFunctionType     = activationFunctionType;
     InitialisationFunctionType = initialisationFunctionType;
 }
Beispiel #2
0
    public Layer(int nodeCount, Layer[] previousGroups, ActivationFunctionType activationFunctionType, InitialisationFunctionType initialisationFunctionType, bool addBiasWeights = true)
    {
        ActivationFunctionType     = activationFunctionType;
        InitialisationFunctionType = initialisationFunctionType;
        PreviousLayers             = previousGroups;

        var nodes = new Node[nodeCount];

        for (var i = 0; i < nodeCount; i++)
        {
            nodes[i] = new Node(previousGroups, addBiasWeights);
        }
        Nodes = nodes;
    }
Beispiel #3
0
    public static Filter1D[] Add1DConvolutionalLayer(this Layer1D[] inputs, int filterCount, int filterSize,
                                                     ActivationFunctionType activationFunction, InitialisationFunctionType initialisationFunction)
    {
        var filters = new Filter1D[filterCount];

        for (var i = 0; i < filterCount; i++)
        {
            filters[i] = new Filter1D(inputs, filterSize, activationFunction, initialisationFunction);
        }
        return(filters);
    }
 public static Func <Random, int, int, double> ResolveInitialisationFunctions(InitialisationFunctionType initialisationFunctionType) =>
 initialisationFunctionType switch
 {
Beispiel #5
0
    public Filter1D(Layer1D[] previousLayers, int filterSize, ActivationFunctionType activationFunctionType, InitialisationFunctionType initialisationFunctionTyp)
        : base(filterSize, previousLayers, activationFunctionType, initialisationFunctionTyp)
    {
        var filterWeightMap = new Dictionary <Layer, Weight[]>();

        foreach (var prevLayer in previousLayers)
        {
            var filterWeights = new Weight[filterSize];
            for (var i = 0; i < filterSize; i++)
            {
                filterWeights[i] = new Weight(0);
            }
            filterWeightMap.Add(prevLayer, filterWeights);
        }

        var prevLayerNodesLength = previousLayers[0].Nodes.Count;
        var nodes = new List <Node>();

        for (var i = 0; i < prevLayerNodesLength - filterSize + 1; i++)
        {
            var node = new Node();
            for (var j = 0; j < filterSize; j++)
            {
                var nodePosition = i + j;
                foreach (var prevLayer in previousLayers)
                {
                    node.Weights.Add(prevLayer.Nodes[nodePosition], filterWeightMap[prevLayer][j]);
                }
            }
            nodes.Add(node);
        }

        Nodes = nodes.ToArray();
    }
Beispiel #6
0
 public Layer1D(int size, Layer[] previousGroups,
                ActivationFunctionType activationFunctionType, InitialisationFunctionType initialisationFunctionType)
     : base(size, previousGroups, activationFunctionType, initialisationFunctionType) =>