Ejemplo n.º 1
0
        public void CanMakeAndReadZeroNetworkMatrix()
        {
            int           neuronCount = 2;
            int           inputcount  = 3;
            WeightsMatrix matrix      = new WeightsMatrix(neuronCount, inputcount);

            double[,] matrixValues = matrix.ToArray();
            Assert.AreEqual(neuronCount, matrix.NumberOfOutputs);
            Assert.AreEqual(inputcount, matrix.NumberOfInputs);
            for (int i = 0; i < neuronCount; i++)
            {
                for (int j = 0; j < inputcount; j++)
                {
                    Assert.AreEqual(0.0, matrixValues[i, j]);
                }
            }
        }
Ejemplo n.º 2
0
        public void CanMultiply()
        {
            NetworkVector vector1 = new NetworkVector(new double[] { 1, 0 });
            NetworkVector vector2 = new NetworkVector(new double[] { 0, 1 });
            WeightsMatrix product = vector1.OuterProduct(vector2);

            double[,] productValues = product.ToArray();
            Assert.AreEqual(0, productValues[0, 0]);
            Assert.AreEqual(1, productValues[0, 1]);
            Assert.AreEqual(0, productValues[1, 0]);
            Assert.AreEqual(0, productValues[1, 1]);

            //double[] array = new double[1000];
            //array[0] = 1;
            //NetworkVector nv = new NetworkVector(array);
            //nv.LeftMultiply(nv);
        }
Ejemplo n.º 3
0
        public void CanSubtract()
        {
            int           neuronCount = 2;
            int           inputcount  = 3;
            WeightsMatrix matrix      = new WeightsMatrix(new double[, ] {
                { 0, 1, 2 }, { 1, 2, 3 }
            });

            matrix.Subtract(matrix);

            double[,] matrixValues = matrix.ToArray();
            for (int i = 0; i < neuronCount; i++)
            {
                for (int j = 0; j < inputcount; j++)
                {
                    Assert.AreEqual(0, matrixValues[i, j]);
                }
            }
        }