Esempio n. 1
0
 public static ushort EnCodeIConduction(IConduction conduction)
 {
     return(conduction switch
     {
         Sigmoind _ => 1,
         ReLU _ => 2,
         SoftReLU _ => 3,
         Straight _ => 4,
         SoftMax _ => 5,
         _ => throw new ArgumentException(
             nameof(conduction), $"this type of IConduction is not registered. {conduction}"),
     });
        public NeuralNetworkInitializer AddLayer(
            IConduction conduction, params int[] node_counts)
        {
            if (layers == null)
            {
                throw new Exception("The layers input is not set yet.");
            }

            if (last_layer_input_count < 0)
            {
                throw new Exception("The layers are closed.");
            }

            if (node_counts == null || node_counts.Length == 0)
            {
                return(this);
            }

            foreach (var node_count in node_counts)
            {
                if (node_count < 1)
                {
                    throw new ArgumentOutOfRangeException(nameof(node_count));
                }

                var synapse = Matrix <double> .Build.Random(
                    node_count, last_layer_input_count, distribution);

                var bias = Vector <double> .Build.Random(node_count, distribution);

                if (absolut_value)
                {
                    synapse = synapse.PointwiseAbs();
                    bias    = bias.PointwiseAbs();
                }

                layers.AddLast(
                    new Layer(conduction)
                {
                    Synapse = synapse,
                    Bias    = bias
                });

                last_layer_input_count = node_count;
            }

            return(this);
        }
Esempio n. 3
0
 public Layer(IConduction conduction)
 {
     Conduction = conduction;
 }