-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests for data loading and model initialization advances #2
These are simple tests to start with. They will be enhanced once I had started to implement my own dataset and try different models.
- Loading branch information
Showing
4 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import pytest | ||
from utils.data_utils import get_dataloaders | ||
|
||
def test_load_cifar10(): | ||
config = { | ||
'data': { | ||
'name': 'CIFAR10', | ||
'dataset_path': './data', | ||
}, | ||
'training': { | ||
'batch_size': 4, | ||
} | ||
} | ||
train_loader, test_loader = get_dataloaders(config) | ||
# Check that loaders are not empty | ||
assert len(train_loader) > 0, "CIFAR10 training loader should not be empty" | ||
assert len(test_loader) > 0, "CIFAR10 test loader should not be empty" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import pytest | ||
import torch | ||
from models.efficientnet import get_efficientnet | ||
from models.resnet import get_resnet | ||
|
||
@pytest.mark.parametrize("model_func, model_name", [ | ||
(get_efficientnet, 'efficientnet_b0'), | ||
(get_resnet, 'resnet18'), | ||
]) | ||
def test_model_initialization_and_forward_pass(model_func, model_name): | ||
model = model_func(model_name, num_classes=10, pretrained=False) | ||
assert model is not None, f"{model_name} should be initialized" | ||
|
||
# Forward pass test | ||
dummy_input = torch.randn(2, 3, 224, 224) | ||
output = model(dummy_input) | ||
assert output.shape == (2, 10), f"Output shape of {model_name} should be (2, 10) for batch size of 2 and 10 classes" |