public void AllocateArrayOfArraysTest()
        {
            var result = ArrayAllocatorUtils.Allocate <double>(2, 3);

            Assert.AreEqual(2, result.Length);
            for (int i = 0; i < 2; i++)
            {
                Assert.AreEqual(3, result[i].Length);
            }
        }
Beispiel #2
0
        public NeuralNet(NeuralNetParameters parameters)
        {
            wagesBetweenInputAndFirstHiddenLayer = ArrayAllocatorUtils.Allocate <double>(parameters.InputLayerSize, parameters.HiddenLayerSize);
            wagesBetweenHiddenLayers             = ArrayAllocatorUtils.Allocate <double>(parameters.NumberOfHiddenLayers - 1, parameters.HiddenLayerSize, parameters.HiddenLayerSize);
            wagesBetweenLastHiddenAndOutputLayer = ArrayAllocatorUtils.Allocate <double>(parameters.HiddenLayerSize, parameters.OutputLayerSize);
            biasesInHiddenLayers = ArrayAllocatorUtils.Allocate <double>(parameters.NumberOfHiddenLayers, parameters.HiddenLayerSize);
            biasesInOutputLayer  = ArrayAllocatorUtils.Allocate <double>(parameters.OutputLayerSize);

            this.activationFunctionType = parameters.ActivationFunctionType;
            activationFunction          = ActivationFunctionFactory.Get(activationFunctionType);
        }
        public void RandomizeArrayOfArraysTest()
        {
            var array = ArrayAllocatorUtils.Allocate <double>(2, 3);

            array.Randomize(-1.0, 1.0);

            foreach (var a in array)
            {
                foreach (var element in a)
                {
                    Assert.AreNotEqual(element, 0.0);
                    Assert.GreaterOrEqual(element, -1.0);
                    Assert.LessOrEqual(element, 1.0);
                }
            }
        }
        public void AllocateArrayTest()
        {
            var result = ArrayAllocatorUtils.Allocate <double>(2);

            Assert.AreEqual(2, result.Length);
        }