From 223b064564e4235e0021344f05b56859ef761088 Mon Sep 17 00:00:00 2001 From: Cian-H Date: Mon, 13 May 2024 15:37:05 +0100 Subject: [PATCH] Tweaked dataloader for more reliable loading --- .gitignore | 2 ++ symbolic_nn_tests/dataloader.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 82f9275..9972241 100644 --- a/.gitignore +++ b/.gitignore @@ -160,3 +160,5 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + +datasets/ diff --git a/symbolic_nn_tests/dataloader.py b/symbolic_nn_tests/dataloader.py index 7a32563..0c78f14 100644 --- a/symbolic_nn_tests/dataloader.py +++ b/symbolic_nn_tests/dataloader.py @@ -1,10 +1,14 @@ +from pathlib import Path from torchvision.datasets import Caltech256 from torch.utils.data import random_split from torch.utils.data import BatchSampler +PROJECT_ROOT = Path(__file__).parent.parent + + def get_dataset(split: (float, float, float) = (0.7, 0.1, 0.2), *args, **kwargs): - ds = Caltech256("../datasets/", download=True) + ds = Caltech256(PROJECT_ROOT / "datasets/", download=True) train, test, val = ( BatchSampler(i, *args, **kwargs) for i in random_split(ds, split) )