Ejemplo n.º 1
0
        public void CreateStandardMLANetwork(int iil, int oil, int nc, int nl)
        {
            PexAssume.InRange(iil, 1, 41);
            PexAssume.InRange(oil, 1, 41);
            PexAssume.InRange(nc, 1, 41);
            PexAssume.InRange(nl, 2, 41);

            var nodeF = new Factory<NeuralNode>(() => new ActivationNeuron(new SigmoidActivationFunction(1.05)));
            var connF = new Factory<NeuralConnection>(() => new Synapse());

            var layers = new NeuralLayerDefinition[nl];

            for (int i = 0; i < nl; i++)
            {
                if (i < (nl - 1))
                {
                    layers[i] = new NeuralLayerDefinition(nodeF, nc);
                }
                else
                {
                    layers[i] = new NeuralLayerDefinition(nodeF, oil);
                }
            }

            var a = new StandardMultilayerArchitecture(new NeuralConnectionDefinition(connF, false), iil, layers);

            var net = a.CreateNetwork();
            net.Iteration();
        }
Ejemplo n.º 2
0
        private static void TestNN()
        {
            var arch = new StandardMultilayerArchitecture
            {
                InitParameters = new OpenCLNNInitParameters
                {
                },
                InputSize = 10,
                HiddenLayers = new[] 
                { 
                    new ActivationLayer(10, new SigmoidActivationFunction()) 
                },
                OutputLayer = new ActivationLayer(2, new LinearActivationFunction())
            };

            using (var nn = (OpenCLNeuralNetwork)arch.CreateNetwork())
            {
                float[] inputs = new float[10];
                float[] outputs = new float[2];

                nn.WriteInput(inputs);

                nn.ReadOutput(outputs);
            }
        }
Ejemplo n.º 3
0
        public void CanCreateSMLCPUTest()
        {
            var arch = new StandardMultilayerArchitecture
            {
                InitParameters = new CPUNNInitParameters(),
                InputSize = 10,
                HiddenLayers = new[] 
                { 
                    new ActivationLayer(10, new SigmoidActivationFunction()) 
                },
                OutputLayer = new ActivationLayer(2, new LinearActivationFunction())
            };

            var nn = arch.CreateNetwork();
            var cpuNN = nn as CPUNeuralNetwork;

            Assert.IsNotNull(nn);
            Assert.IsNotNull(cpuNN);
        }