# **a_i** is a 4D Tensor of shape ``(7, 3, 1000, 1)`` and **not** # a 3D Tensor of shape ``(7, 3, 1000)``. # ############################################################################# # Supported formulas # ------------------------------------ # # The full range of mathematical operations supported by # :class:`LazyTensors<pykeops.torch.LazyTensor>` is described # in our API documentation. # Let's just mention that the lines below define valid computations: # x_i = LazyTensor(torch.randn(A, B, M, 1, D)) l_i = LazyTensor(torch.randn(1, 1, M, 1, D)) y_j = LazyTensor(torch.randn(1, B, 1, N, D)) s = LazyTensor(torch.rand(A, 1, 1, 1, 1)) F_ij = (x_i**1.5 + y_j / l_i).cos() - (x_i | y_j) + (x_i[:, :, :, :, 2] * s.relu() * y_j) print(F_ij) a_j = F_ij.sum(dim=2) print("a_j is now a {} of shape {}.".format(type(a_j), a_j.shape)) ############################################################################# # Enjoy! And feel free to check the next tutorial for a discussion # of the varied reduction operations that can be applied to # KeOps :class:`LazyTensors<pykeops.torch.LazyTensor>`.
# **a_i** is a 4D Tensor of shape ``(7, 3, 1000, 1)`` and **not** # a 3D Tensor of shape ``(7, 3, 1000)``. # ############################################################################# # Supported formulas # ------------------------------------ # # The full range of mathematical operations supported by # :class:`LazyTensors<pykeops.torch.LazyTensor>` is described # in our API documentation. # Let's just mention that the lines below define valid computations: # x_i = LazyTensor(torch.randn(A, B, M, 1, D)) l_i = LazyTensor(torch.randn(1, 1, M, 1, D)) y_j = LazyTensor(torch.randn(1, B, 1, N, D)) s = LazyTensor(torch.rand(A, 1, 1, 1, 1)) F_ij = (x_i ** 1.5 + y_j / l_i).cos() - (x_i | y_j) + (x_i[:, :, :, :, 2] * s.relu() * y_j) print(F_ij) a_j = F_ij.sum(dim=2) print("a_j is now a {} of shape {}.".format(type(a_j), a_j.shape)) ############################################################################# # Enjoy! And feel free to check the next tutorial for a discussion # of the varied reduction operations that can be applied to # KeOps :class:`LazyTensors<pykeops.torch.LazyTensor>`.
# **a_i** is a 4D Tensor of shape ``(7, 3, 1000, 1)`` and **not** # a 3D Tensor of shape ``(7, 3, 1000)``. # ############################################################################# # Supported formulas # ------------------------------------ # # The full range of mathematical operations supported by # :class:`LazyTensors<pykeops.torch.LazyTensor>` is described # in our API documentation. # Let's just mention that the lines below define valid computations: # x_i = LazyTensor(torch.randn(A, B, M, 1, D)) l_i = LazyTensor(torch.randn(1, 1, M, 1, D)) y_j = LazyTensor(torch.randn(1, B, 1, N, D)) s = LazyTensor(torch.rand(A, 1, 1, 1, 1)) F_ij = ((x_i**1.5 + y_j / l_i).cos() - (x_i | y_j) + (x_i[:, :, :, :, 2] * s.relu() * y_j)) print(F_ij) a_j = F_ij.sum(dim=2) print("a_j is now a {} of shape {}.".format(type(a_j), a_j.shape)) ############################################################################# # Enjoy! And feel free to check the next tutorial for a discussion # of the varied reduction operations that can be applied to # KeOps :class:`LazyTensors<pykeops.torch.LazyTensor>`.