grid_size = grid.size(-2)
grid_dim = grid.size(-1)
grid_data = torch.zeros(int(pow(grid_size, grid_dim)), grid_dim)
prev_points = None
for i in range(grid_dim):
for j in range(grid_size):
grid_data[j * grid_size ** i : (j + 1) * grid_size ** i, i].fill_(grid[j, i])
if prev_points is not None:
grid_data[j * grid_size ** i : (j + 1) * grid_size ** i, :i].copy_(prev_points)
prev_points = grid_data[: grid_size ** (i + 1), : (i + 1)]
class TestGridKernel(unittest.TestCase):
def test_grid_grid(self):
After Change
from gpytorch.utils.grid import create_data_from_grid
grid = [torch.linspace(0, 1, 5), torch.linspace(0, 2, 3)]
d = len(grid)
grid_data = create_data_from_grid(grid)