Exemplo n.º 1
0
        private void backward_convolute_on_depth(UnitLayer to, int stride, int depth, int length)
        {
            int to_depth = depth + length;

            if (to_depth >= Depth)
            {
                to_depth = Depth;
            }

            for (int d = depth; d < to_depth; d++)
            {
                WeightLayer weights = WeightLayerPool.find(to.Id, Id, d);

                int width_of_weights = weights.Width, height_of_weights = weights.Height;

                for (int y = 0; y < Height; y++)
                {
                    int top = y * stride;

                    int bottom = top + height_of_weights;

                    for (int x = 0; x < Width; x++)
                    {
                        int left = x * stride;

                        to.diff_convolute_product(left, top, left + width_of_weights, bottom, Units[x, y, d].gradient_at_inport, weights);
                    }
                }

                weights.diff_weights();
            }
        }
Exemplo n.º 2
0
        private void backward_fully_connect_on_depth(UnitLayer to, int depth, int length)
        {
            int to_depth = depth + length;

            if (to_depth >= Depth)
            {
                to_depth = Depth;
            }

            for (int d = depth; d < to_depth; d++)
            {
                for (int y = 0; y < Height; y++)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        WeightLayer weights = WeightLayerPool.find(to.Id, Id, x, y, d);

                        to.diff_fully_product(Units[x, y, d].gradient_at_inport, weights);

                        weights.diff_weights();
                    }
                }
            }
        }