Пример #1
0
        public void TestConstructor()
        {
            LayerStub prevLayer = new LayerStub(4, 4, 2);

            MaxPoolingLayer layer = new MaxPoolingLayer(2, 2, prevLayer);

            Assert.AreEqual(2, layer.Width);
            Assert.AreEqual(2, layer.Height);
            Assert.AreEqual(prevLayer.Depth, layer.Depth);
        }
Пример #2
0
        public void TestCalculateErrorByOutputGradient()
        {
            LayerStub       prevLayer = new LayerStub(4, 4, 2);
            MaxPoolingLayer layer     = new MaxPoolingLayer(2, 2, prevLayer);



            //PrivateObject obj = new PrivateObject(layer);
            //int[] maxIndices = new[] { 5, 7, 13, 15 };

            //for (int fNIdx = 0; fNIdx < prevLayer.Neurons; fNIdx++) {
            //    for (int tNIdx = 0; tNIdx < layer.Neurons; tNIdx++) {
            //        float weight = (float)obj.Invoke("GetWeight", maxIndices, fNIdx, tNIdx);


            //    }
            //}
        }
Пример #3
0
        public void TestFeedForward()
        {
            float[] data = new float[4 * 4 * 2];
            for (int i = 0; i < data.Length; i++)
            {
                data[i] = i + 1;
            }
            LayerStub       prevLayer = new LayerStub(4, 4, 2);
            MaxPoolingLayer layer     = new MaxPoolingLayer(2, 2, prevLayer);
            NNFeedData      feedData  = new NNFeedData(4, 4, 2, data);

            NNDetailedFeedData result = layer.FeedForward(feedData);

            Assert.AreEqual(6, result.OutputData[result.OutputData.ToNeuronIndex(0, 0, 0)]);
            Assert.AreEqual(8, result.OutputData[result.OutputData.ToNeuronIndex(1, 0, 0)]);
            Assert.AreEqual(14, result.OutputData[result.OutputData.ToNeuronIndex(0, 1, 0)]);
            Assert.AreEqual(16, result.OutputData[result.OutputData.ToNeuronIndex(1, 1, 0)]);
        }