image = [[1, 2, 0], [0, 1, 3], [2, 0, 1]]
kernel = [[1, -1], [0, 1]]
# Cross-correlation, stride=1, no padding, one input channel.
feature = [[sum(image[i+a][j+b]*kernel[a][b]
                for a in range(2) for b in range(2))
            for j in range(2)] for i in range(2)]
relu = [[max(0, value) for value in row] for row in feature]
pooled = max(value for row in relu for value in row)
print('feature', feature)
print('ReLU', relu, 'max pool', pooled)
assert feature == [[0, 5], [-1, -1]]
assert relu == [[0, 5], [0, 0]] and pooled == 5
