From f04c2f3e2f6ee2883c04bae8d895b47db9bea14a Mon Sep 17 00:00:00 2001 From: seilmast Date: Sun, 23 Feb 2025 17:37:57 +0100 Subject: [PATCH 1/3] Fixed all tests on main --- tests/test_wrappers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_wrappers.py b/tests/test_wrappers.py index 3a6ca75..c5c3dff 100644 --- a/tests/test_wrappers.py +++ b/tests/test_wrappers.py @@ -50,9 +50,10 @@ def test_load_data(): ) for name in dataset_names: - dataset = load_data(name, train=False, data_dir=Path.cwd() / "Data", transform=trans) - - im, _ = dataset.__getitem__(0) + dataset, _, _ = load_data( + name, train=False, data_dir=Path.cwd() / "Data", transform=trans + ) + im, _ = dataset[0] assert dataset.__len__() != 0 assert type(im) is th.Tensor and len(im.size()) == 3 From 084dee2dae8a2042c4dc721ad722e181f8a62f13 Mon Sep 17 00:00:00 2001 From: seilmast Date: Sun, 23 Feb 2025 18:12:25 +0100 Subject: [PATCH 2/3] All tests are fixed! --- CollaborativeCoding/dataloaders/download.py | 6 +++--- CollaborativeCoding/models/magnus_model.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CollaborativeCoding/dataloaders/download.py b/CollaborativeCoding/dataloaders/download.py index 4baefe2..e1eeed9 100644 --- a/CollaborativeCoding/dataloaders/download.py +++ b/CollaborativeCoding/dataloaders/download.py @@ -98,11 +98,11 @@ def download_svhn(path, train: bool = True): train_data = parent_path / "train_32x32.mat" test_data = parent_path / "test_32x32.mat" - if not train_data.exists(): + if not train_data.is_file(): download_svhn(parent_path, train=True) - if not test_data.exists(): + if not test_data.is_file(): download_svhn(parent_path, train=False) - + print(test_data) train_labels = loadmat(train_data)["y"] test_labels = loadmat(test_data)["y"] diff --git a/CollaborativeCoding/models/magnus_model.py b/CollaborativeCoding/models/magnus_model.py index 7a79057..244a5ff 100644 --- a/CollaborativeCoding/models/magnus_model.py +++ b/CollaborativeCoding/models/magnus_model.py @@ -2,7 +2,7 @@ class MagnusModel(nn.Module): - def __init__(self, image_shape, num_classes: int, nr_channels: int = 1): + def __init__(self, image_shape, num_classes: int): """ Initializes the MagnusModel, a neural network designed for image classification tasks. The model consists of three linear layers, each with 133 neurons, and uses ReLU activation @@ -14,11 +14,11 @@ def __init__(self, image_shape, num_classes: int, nr_channels: int = 1): nr_channels (int): The number of channels in the input image. """ super().__init__() - *_, H, W = image_shape + C, H, W = image_shape[-3], image_shape[-2], image_shape[-1] self.layer1 = nn.Sequential( *( [ - nn.Linear(nr_channels * H * W, 133), + nn.Linear(C * H * W, 133), nn.ReLU(), ] ) From 854811798c724cbb856ff0c96eb5f73f5b74c033 Mon Sep 17 00:00:00 2001 From: seilmast Date: Sun, 23 Feb 2025 20:29:26 +0100 Subject: [PATCH 3/3] Does this fix the issues?