def test_roi_pooling(): A = np.ones((1, 1, 5, INT_OVERFLOW)) A[0][0][0][2] = 100 roi = np.array([[0, 0, 0, 3, 3]]) A.attach_grad() with mx.autograd.record(): B = npx.roi_pooling(A, roi, pooled_size=(2, 2), spatial_scale=1) assert B.shape == (1, 1, 2, 2) assert B[0][0][0][1] == 100 B.backward() assert A.grad.shape == (1, 1, 5, INT_OVERFLOW) assert A.grad[0][0][0][0] == 1
def test_roi_pooling(): def test_roi_pooling_large_dim(): A = np.ones((1, 1, INT_OVERFLOW, 5)) roi = np.array([[0, 0, 0, 5, 5]]) assertRaises(MXNetError, npx.roi_pooling, A, roi, pooled_size=(3, 3), \ spatial_scale=1) test_roi_pooling_large_dim() H, W = 2**16, 2**16 A = np.ones((1, 1, H, W)) A[0, 0, 0, 2] = 100 roi = np.array([[0, 0, 0, 5, 5]]) A.attach_grad() with mx.autograd.record(): B = npx.roi_pooling(A, roi, pooled_size=(3, 3), spatial_scale=1) assert B.shape == (1, 1, 3, 3) assert B[0][0][0][1] == 100 B.backward() assert A.grad.shape == (1, 1, H, W) assert A.grad[0][0][0][0] == 1