|
30 | 30 | @test_utils.run_all_in_graph_and_eager_modes |
31 | 31 | class InterpolateBilinearTest(tf.test.TestCase): |
32 | 32 | def test_interpolate_small_grid_ij(self): |
33 | | - grid = tf.constant([[0., 1., 2.], [3., 4., 5.], [6., 7., 8.]], |
34 | | - shape=[1, 3, 3, 1]) |
35 | | - query_points = tf.constant([[0., 0.], [1., 0.], [2., 0.5], [1.5, 1.5]], |
36 | | - shape=[1, 4, 2]) |
37 | | - expected_results = np.reshape(np.array([0., 3., 6.5, 6.]), [1, 4, 1]) |
| 33 | + grid = tf.constant( |
| 34 | + [[0., 1., 2.], [3., 4., 5.], [6., 7., 8.], [9., 10., 11.]], |
| 35 | + shape=[1, 4, 3, 1]) |
| 36 | + query_points = tf.constant( |
| 37 | + [[0., 0.], [1., 0.], [2., 0.5], [1.5, 1.5], [3., 2.]], |
| 38 | + shape=[1, 5, 2]) |
| 39 | + expected_results = np.reshape( |
| 40 | + np.array([0., 3., 6.5, 6., 11.]), [1, 5, 1]) |
38 | 41 |
|
39 | 42 | interp = interpolate_bilinear(grid, query_points) |
40 | 43 |
|
41 | 44 | self.assertAllClose(expected_results, interp) |
42 | 45 |
|
43 | 46 | def test_interpolate_small_grid_xy(self): |
44 | | - grid = tf.constant([[0., 1., 2.], [3., 4., 5.], [6., 7., 8.]], |
45 | | - shape=[1, 3, 3, 1]) |
| 47 | + grid = tf.constant( |
| 48 | + [[0., 1., 2.], [3., 4., 5.], [6., 7., 8.], [9., 10., 11.]], |
| 49 | + shape=[1, 4, 3, 1]) |
46 | 50 | query_points = tf.constant( |
47 | | - [[0., 0.], [0., 1.], [0.5, 2.0], [1.5, 1.5]], shape=[1, 4, 2]) |
48 | | - expected_results = np.reshape(np.array([0., 3., 6.5, 6.]), [1, 4, 1]) |
| 51 | + [[0., 0.], [0., 1.], [0.5, 2.0], [1.5, 1.5], [2., 3.]], |
| 52 | + shape=[1, 5, 2]) |
| 53 | + expected_results = np.reshape( |
| 54 | + np.array([0., 3., 6.5, 6., 11.]), [1, 5, 1]) |
49 | 55 |
|
50 | 56 | interp = interpolate_bilinear(grid, query_points, indexing="xy") |
51 | 57 |
|
|
0 commit comments