public void MaxPoolingTest() { var input = MatrixProcessor.MaxPool(new double[5, 5] { { 5, 2, 1, 9, 8 }, { 3, 1, 2, 3, 5 }, { 0, 6, 2, 8, 1 }, { 3, 4, 9, 2, 1 }, { 6, 3, 1, 2, 2 } }, 2); var actual = MatrixProcessor.ReverseMaxPool(new double[3, 3] { { 3, 3, 3 }, { 3, 3, 3 }, { 3, 3, 3 } }, 2, 5, input.MaxCoordinates); var expected = new double[5, 5] { { 3, 0, 0, 3, 3 }, { 0, 0, 0, 0, 0 }, { 0, 3, 0, 0, 3 }, { 0, 0, 3, 0, 0 }, { 3, 0, 0, 3, 3 } }; for (int i = 0; i < actual.GetLength(0); i++) { for (int j = 0; j < actual.GetLength(1); j++) { Assert.AreEqual(actual[i, j], expected[i, j]); } } }
public override Value PassForward(Value value) { var res = MatrixProcessor.MaxPool(value.Multi, _kernelSize); _maxValues.ForEach((k, i, j) => _maxValues[k, i, j] = res.Item2[k, i, j]); return(new MultiValue(res.Item1)); }
public void NewMaxPoolingTest() { var input = new double[, , ] { { { 53, 29, 3, 55, 2 }, { 70, 14, 35, 96, 21 }, { 54, 64, 66, 70, 16 }, { 16, 68, 1, 6, 99 }, { 83, 93, 61, 90, 37 } }, { { 69, 11, 11, 83, 63 }, { 24, 54, 58, 61, 12 }, { 96, 7, 1, 36, 2 }, { 75, 21, 64, 49, 96 }, { 89, 51, 46, 91, 31 }, } }; var expected = new double[, , ] { { { 70, 96, 21 }, { 68, 70, 99 }, { 93, 90, 37 } }, { { 69, 83, 63 }, { 96, 64, 96 }, { 89, 91, 31 }, } }; var expected2 = new bool[, , ] { { { false, false, false, false, false }, { true, false, false, true, true }, { false, false, false, true, false }, { false, true, false, false, true }, { false, true, false, true, true } }, { { true, false, false, true, true }, { false, false, false, false, false }, { true, false, false, false, false }, { false, false, true, false, true }, { true, false, false, true, true }, } }; var actual = MatrixProcessor.MaxPool(input, 2); Helper.CompareArrays(expected, actual.Item1); Helper.CompareArrays(expected2, actual.Item2); }