Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ybubnov/torch_geopooling
The geospatial pooling modules for neural networks in PyTorch
https://github.com/ybubnov/torch_geopooling
deep-learning deep-learning-library geospatial machine-learning python pytorch
Last synced: about 8 hours ago
JSON representation
The geospatial pooling modules for neural networks in PyTorch
- Host: GitHub
- URL: https://github.com/ybubnov/torch_geopooling
- Owner: ybubnov
- License: gpl-3.0
- Created: 2024-02-26T18:54:04.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-09-10T18:30:10.000Z (23 days ago)
- Last Synced: 2024-09-10T19:44:35.842Z (23 days ago)
- Topics: deep-learning, deep-learning-library, geospatial, machine-learning, python, pytorch
- Language: C++
- Homepage: https://torch-geopooling.readthedocs.io
- Size: 7.14 MB
- Stars: 16
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Torch Geopooling - The geospatial pooling library for PyTorch
The Torch Geopooling library is an extension for PyTorch library that provide extra layers for
building geospatial neural networks.Here is an example of how you can use modules from Torch Geopooling library to train neural
networks predicting geospatial features:
![example](docs/index.png)## Installation
The library is distributed as PyPI package, to install that package, execute the following
command:
```sh
pip install torch_geopooling
```You can use the `torch_geopooling` library for building neural networks with geospatial indexing.
The interface of the provided modules is compatible with [PyTorch](https://pytorch.org) library,
including automatic gradient computation.## Documentation
The [Torch Geopooling Documentation](https://torch-geopooling.readthedocs.org) contains additional
details on how to get started with this library as well a few examples of training neural networks
that use geo-pooling modules.## Usage
The module provides adaptive and regular modules that implement decomposition of point coordinates
in 2-dimensional space. Decomposition in this context implies separation of the space into
rectangles (quads).Adaptive modules are building the decomposition during the training, while for regular modules
the decomposition should be computed beforehand. As a result, adaptive module builds sparse
decomposition, while regular module builds dense (regular) decomposition.Using adaptive decomposition module for [EPSG:4326](https://epsg.io/4326) coordinates:
```py
import torch
from torch_geopooling.nn import AdaptiveQuadPool2d# Create 5-feature vector for each node in a decomposition.
pool = AdaptiveQuadPool2d(5, (-180, -90, 360, 180), max_depth=12, capacity=10)
input = torch.DoubleTensor(1024, 2).uniform_(-90, 90)
output = pool(input)
```Using regular decomposition module for arbitrary polygon:
```py
import torch
from shapely import Polygon
from torch_geopooling.nn import QuadPool2d# Polygon for regular decomposition should be within an exterior boundary.
poly = Polygon([(0.0, 0.0), (10.0, 0.0), (10.0, 10.0), (0.0, 10.0)])
exterior = (-100.0, -100.0, 200.0, 200.0)
# Create 3-feature vector for each node in a decomposition.
pool = QuadPool2d(3, poly, exterior, max_depth=10)
input = torch.DoubleTensor(200, 2).uniform_(0.0, 10.0)
output = pool(input)
```Using 2-dimensional embedding module for learning data on sphere:
```py
import torch
from torch_geopooling.nn import Embedding2dembedding = Embedding2d((16, 16, 2), padding=(3, 3), exterior=(-100, 100, 200.0, 200.0))
input = torch.DoubleTensor(1024, 2).normal_(5.0, 1.0)
output = embedding(input)
```## License
The Torch Geopooling is distributed under GPLv3 license. See the [LICENSE](LICENSE) file for full
license text.