private double[][][] formErrors(final double[][][] newErrors) {
        int maxLayer = Integer.MIN_VALUE;
        for (final int[] line : myMask) {
            for (final int value : line) {
                if (value > maxLayer) {
                    maxLayer = value;
                }
            }
        }

        final int length = newErrors[0].length;
        final double[][][] errors = new double[maxLayer + 1][length][length];
        final int maskLength = myMask.length;
        for (int i = 0; i < maskLength; ++i) {
            final int[] ints = myMask[i];
            for (final int layer : ints) {
                for (int x = 0; x < length; ++x) {
                    for (int y = 0; y < length; ++y) {
                        errors[layer][x][y] += newErrors[i][x][y];
                    }
                }
            }
        }

        return errors;
    }