Skip to content

Dataset CLI

The dataset CLI exposes the public dataset registry used by the examples and notebooks. It can list supported tabular and TorchVision datasets or download them into a local data directory.

Use the console command when installed, or call the module directly:

silva-datasets --list
python -m silva_networks.dataset_cli --list
python -m silva_networks.dataset_cli --root data iris wine
python -m silva_networks.dataset_cli --torchvision --split train CIFAR10

Dataset files are not committed to the repository. The CLI delegates to the same public helpers documented in Datasets.

From Dataset to SILVA State

The command downloads raw records; model adaptation remains explicit. For a tabular dataset with \(N\) rows and \(d_{\rm in}\) features, the common route is

\[ X\in\mathbb R^{N\times d_{\rm in}} \longrightarrow (X,E,b) \longrightarrow Z^\star\in\mathbb R^{N\times d_{\rm hidden}}. \]
from silva_networks import load_tabular_dataset, tabular_to_silva_graph

dataset = load_tabular_dataset("iris", root="data", download=False, normalize=True)
graph = tabular_to_silva_graph(dataset, k=8, normalize=True)
graph.validate()

print(graph.x.shape, graph.edge_index.shape, graph.y.shape)

Use download=False after the first successful retrieval when an experiment must avoid network access. GraphTensorBatch.validate() checks feature rank, edge shape and bounds, label alignment, and optional batch assignments before the data reaches a SILVA transition.

Command Outcomes

Command Result
--list names and descriptions of tabular datasets
--list --torchvision supported image-dataset names
--root PATH NAME download or verify a tabular dataset under PATH
--torchvision --split SPLIT NAME download or verify an image split

For preprocessing equations and custom dataset adapters, continue with Datasets and Preprocessing and the Dataset Quickstart.

main

main()

Download or list package-supported public datasets from the command line.

Source code in src/silva_networks/dataset_cli.py
def main() -> None:
    """Download or list package-supported public datasets from the command line."""

    parser = argparse.ArgumentParser(description="Download public datasets for SILVA examples.")
    parser.add_argument("--root", type=Path, default=Path("data"))
    parser.add_argument("--force", action="store_true")
    parser.add_argument("--list", action="store_true", help="List registered datasets and exit.")
    parser.add_argument(
        "--torchvision",
        action="store_true",
        help="Use the optional TorchVision dataset registry instead of tabular UCI files.",
    )
    parser.add_argument("--split", default="train", choices=["train", "test"])
    parser.add_argument("names", nargs="*", help="Dataset names. Omit to download all registered datasets.")
    args = parser.parse_args()

    if args.list:
        if args.torchvision:
            rows = [
                {
                    "name": name,
                    "task": "classification",
                    "source": "TorchVision dataset registry",
                    "description": "Image dataset loaded through silva_networks.load_torchvision_dataset.",
                }
                for name in available_torchvision_datasets()
            ]
        else:
            rows = [
                {
                    "name": name,
                    "task": dataset_info(name).task,
                    "source": dataset_info(name).source,
                    "description": dataset_info(name).description,
                }
                for name in available_datasets()
            ]
        print(json.dumps(rows, indent=2))
        return

    if args.torchvision:
        selected = args.names or list(available_torchvision_datasets())
        loaded = {}
        for name in selected:
            dataset = load_torchvision_dataset(
                name,
                root=args.root,
                train=args.split == "train",
                download=True,
            )
            loaded[name] = {"root": str(args.root), "items": len(dataset)}
        print(json.dumps(loaded, indent=2))
        return

    selected = args.names or available_datasets()
    paths = download_many(selected, root=args.root, force=args.force)
    print(json.dumps({name: str(path) for name, path in paths.items()}, indent=2))

Where to Go Next

Question Page
How should downloaded tensors be validated? Datasets and Preprocessing
Which dataset objects are returned? Datasets API
Which complete commands are available? CLI Guide