Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cifar100 wrn404 regularization #31

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deepobs/pytorch/testproblems/cifar100_wrn404.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ def get_regularization_groups(self):
group_dict[l2].append(parameters)
else:
group_dict[no].append(parameters)

return group_dict
11 changes: 8 additions & 3 deletions tests/pytorch/testproblems/test_cifar100_wrn404.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ def setUp(self):
"""Sets up CIFAR-100 dataset for the tests."""
self.batch_size = 100
self.cifar100_wrn404 = testproblems.cifar100_wrn404(self.batch_size)

def test_num_param(self):
"""Tests the number of parameters."""
torch.manual_seed(42)
self.cifar100_wrn404.set_up()
self.cifar100_wrn404.train_init_op()

def test_num_param(self):
"""Tests the number of parameters."""
num_param = []
for parameter in self.cifar100_wrn404.net.parameters():
num_param.append(parameter.numel())
Expand Down Expand Up @@ -155,6 +155,11 @@ def test_num_param(self):

self.assertEqual(num_param, expected_num_param)

def test_forward_pass_with_regularization(self):
loss, _ = self.cifar100_wrn404.get_batch_loss_and_accuracy(
add_regularization_if_available=True
)


if __name__ == "__main__":
unittest.main()