datasets-and-samplers
Use for TorchGeo GeoDataset/NonGeoDataset usage, dataset composition, raster/vector dataset implementation, sample dictionaries, collate functions, and patch samplers.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- datasets-and-samplers
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Use for TorchGeo GeoDataset/NonGeoDataset usage, dataset composition, raster/vector dataset implementation, sample dictionaries, collate functions, and patch samplers.
- disable-model-invocation
- true
02 资源文件 1
- 参考文档references/datasets-and-samplers.md2.4 KB
03 SKILL.md 正文
TorchGeo datasets and samplers
Use this sub-skill for dataset selection, custom dataset implementation, geospatial composition, patch sampling, data loader collation, and dataset tests.
Choose the dataset family
- Use
GeoDatasetwhen samples are queried by geospatial extent/time and the dataset has CRS/resolution/geometry metadata. These datasets support spatial/temporal indexing and composition. - Use
NonGeoDatasetfor torchvision-style benchmark datasets indexed by integer sample id and usually stored under arootdirectory. - Raster-like geospatial datasets should normally subclass TorchGeo raster/vector helpers rather than manually reimplementing file indexing. Confirm the expected base class in the adjacent dataset source and tests before editing.
Compose geospatial datasets
dataset_a & dataset_bcreates anIntersectionDataset: every query must be available in both datasets. Use this for image + mask/label/elevation/data-fusion workflows.dataset_a | dataset_bcreates aUnionDataset: a query may be satisfied by either dataset. Use this for alternate sensors or adjacent regions.- Composition is meaningful only when the participating indexes share compatible CRS/resolution/time assumptions. If outputs look empty, inspect bounds, CRS, resolution, and time interval overlap.
Sample dictionary expectations
Common keys:
image: tensor shaped like(C, H, W)for a single sample or batched by a collate function.mask: semantic/change/instance segmentation target.label: classification/regression target.bbox_xyxy: object detection boxes in xyxy format.- metadata keys such as
crs,bounds, dates, filenames, or dataset-specific attributes.
Always read the dataset test fixture before assuming keys. Use stack_samples for ordinary tensor dictionaries; use detection-specific collate helpers when boxes/masks are variable length.
Sampler selection
- Use
RandomPatchSampler(dataset, size=..., length=...)for stochastic training chips from aGeoDataset. - Use gridded samplers for deterministic tiling, validation, or prediction over a region.
- Use batch samplers when the sampler should yield lists of geospatial windows directly.
- Pass
roifor a spatial region of interest andtoifor a time interval of interest. Verify that ROI and TOI intersectdataset.index. - Check the
unitsargument where available: pixel units are converted using dataset resolution, while CRS units are already in projected units.
Dataset implementation checklist
- Add or update the dataset class in
torchgeo/datasets/<name>.pywith the TorchGeo license header. - Choose
GeoDataset,NonGeoDataset, raster, or vector base class based on indexing semantics. - Keep
root='data'default when adding a new dataset unless an existing nearby class uses a different convention. - Implement
_verify()/download/checksum behavior consistently with adjacent datasets. - Return a sample dictionary with documented keys and stable tensor shapes.
- Add import/export wiring in
torchgeo/datasets/__init__.py. - Add fake fixture generation under
tests/data/<dataset>/and a focusedtests/datasets/test_<dataset>.pywith plot/download/checksum/error coverage as applicable. - Update docs tables and RST pages when the public dataset catalog changes.
Read next
- reference for deeper API facts and failure modes.
- Root troubleshooting for install and dependency issues.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).