embedding2d¶
- torch_geopooling.functional.embedding2d(input: Tensor, weight: Tensor, *, padding: Tuple[int, int] = (0, 0), exterior: Tuple[float, float, float, float], reflection: bool = True) Tensor[source]¶
Retrieves spatial embeddings from a fixed-size lookup table based on 2D coordinates.
This function accepts a list of (x, y) coordinates and retrieves the corresponding spatial embeddings from a provided embedding matrix. The embeddings are selected based on the input coordinates, with an optional padding to include neighboring cells. See
torch_geopooling.nn.Embedding2dfor more details.- Parameters:
input – A list of 2D coordinates where each coordinate is represented as a tuple (x, y), where x is the longitude and y is the latitude.
weight – A 3D tensor representing the embedding matrix. The first dimension corresponds to the maximum possible bucket for the x coordinate, the second dimension corresponds to the maximum possible bucket for the y coordinate, and the third dimension corresponds to the embedding size.
padding – The size of the neighborhood to query. Default is 0, meaning only the embedding for the exact input coordinate is retrieved.
exterior – The geometric boundary of the learning space, specified as a tuple (X, Y, W, H), where X and Y represent the origin, and W and H represent the width and height of the space, respectively.
reflection – When true, kernel is wrapped around the exterior space, otherwise kernel is squeezed into borders.
- Returns:
The retrieved spatial embeddings corresponding to the input coordinates.
- Return type:
Tensor