Skip to content

Commit

Permalink
change model architecture, update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
fvarno committed Sep 10, 2022
1 parent b46fc06 commit 19136f3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
0.7.0 (2022-09-10)
------------------

* algorithms got more secure with local storage
* redefined model architectures
* fixed bug in default step closure'
* made random seed more consistent

0.6.2 (2022-08-31)
------------------

Expand Down
27 changes: 21 additions & 6 deletions fedsim/models/simple_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class SimpleMLP(nn.Module):
Args:
num_classes (int, optional): number of classes. Defaults to 10.
Assigning None or a negative integer means no classifier.
num_channels (int, optional): number of channels of input. Defaults to 1.
in_height (int, optional): input height to resize to. Defaults to 28.
in_width (int, optional): input width to resize to. Defaults to 28.
Expand All @@ -46,11 +47,15 @@ def __init__(
self.resize = Resize((in_height, in_width))
self.fc1 = nn.Linear(num_channels * in_height * in_width, feature_size)
self.fc2 = nn.Linear(feature_size, feature_size)
self.classifier = nn.Linear(feature_size, num_classes)
if num_classes is not None and num_classes > 0:
self.classifier = nn.Linear(feature_size, num_classes)
else:
self.classifier = None

def forward(self, x):
x = self.get_features(x)
x = self.classifier(x)
if self.classifier is not None:
x = self.classifier(x)
return x

def get_features(self, x):
Expand All @@ -77,6 +82,7 @@ class SimpleCNN(nn.Module):
Args:
num_classes (int, optional): number of classes. Defaults to 10.
Assigning None or a negative integer means no classifier.
num_channels (int, optional): number of channels of input. Defaults to 1.
in_height (int, optional): input height to resize to. Defaults to 28.
in_width (int, optional): input width to resize to. Defaults to 28.
Expand Down Expand Up @@ -123,11 +129,15 @@ def __init__(
out_w = get_output_size(out_w, 1, 2, 2)

self.fc = nn.Linear(num_filters2 * out_w * out_h, feature_size)
self.classifier = nn.Linear(feature_size, num_classes)
if num_classes is not None and num_classes > 0:
self.classifier = nn.Linear(feature_size, num_classes)
else:
self.classifier = None

def forward(self, x):
x = self.get_features(x)
x = self.classifier(x)
if self.classifier is not None:
x = self.classifier(x)
return x

def get_features(self, x):
Expand Down Expand Up @@ -158,6 +168,7 @@ class SimpleCNN2(nn.Module):
Args:
num_classes (int, optional): number of classes. Defaults to 10.
Assigning None or a negative integer means no classifier.
num_channels (int, optional): number of channels of input. Defaults to 1.
in_height (int, optional): input height to resize to. Defaults to 28.
in_width (int, optional): input width to resize to. Defaults to 28.
Expand Down Expand Up @@ -207,11 +218,15 @@ def __init__(

self.fc1 = nn.Linear(num_filters2 * out_w * out_h, hidden_size)
self.fc2 = nn.Linear(hidden_size, feature_size)
self.classifier = nn.Linear(feature_size, num_classes)
if num_classes is not None and num_classes > 0:
self.classifier = nn.Linear(feature_size, num_classes)
else:
self.classifier = None

def forward(self, x):
x = self.get_features(x)
x = self.classifier(x)
if self.classifier is not None:
x = self.classifier(x)
return x

def get_features(self, x):
Expand Down

0 comments on commit 19136f3

Please sign in to comment.