Thanks @ptrblck for the information… I have been trying to fetch weights and biases of a model separately and
for k in local_model.keys():
#` print(“([client_models[i].state_dict()”,client_models[i].state_dict()[k])
if “weight” in k:
append in localdict after detaching and flatten()
convert into numpy
#print(“local_dict.append”,local_dict)
if “bias” in k:
append in localdict1 after detaching and flatten()
convert into numpy
hstack localdict and localdict1 to get a dictionary of weights and biases
Now I am passing it to neighbors_fit = neighbors.fit(local_dict2) to get the epsilon value of dbscan clustering but it fails:
TypeError: only size-1 arrays can be converted to Python scalars
ValueError: setting an array element with a sequence.
How can I stack weights and biases and fit it to neighbors.fit() without getting this error.
My model is as follows:
5328
Net1(
(pool): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
(convblock1): Sequential(
(0): Conv2d(1, 8, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(1): BatchNorm2d(8, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU()
(3): Dropout(p=0.025, inplace=False)
)
(convblock2): Sequential(
(0): Conv2d(8, 16, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(1): BatchNorm2d(16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU()
(3): Dropout(p=0.025, inplace=False)
)
(trans1): Sequential(
(0): Conv2d(16, 4, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(4, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU()
(3): Dropout(p=0.025, inplace=False)
)
(convblock3): Sequential(
(0): Conv2d(4, 8, kernel_size=(3, 3), stride=(1, 1), bias=False)
(1): BatchNorm2d(8, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU()
(3): Dropout(p=0.025, inplace=False)
(4): Conv2d(8, 16, kernel_size=(3, 3), stride=(1, 1), bias=False)
(5): BatchNorm2d(16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(6): ReLU()
(7): Dropout(p=0.025, inplace=False)
(8): Conv2d(16, 16, kernel_size=(3, 3), stride=(1, 1), bias=False)
(9): BatchNorm2d(16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(10): ReLU()
(11): Dropout(p=0.025, inplace=False)
)
(gap): Sequential(
(0): AvgPool2d(kernel_size=8, stride=8, padding=0)
)
(convblock5): Sequential(
(0): Conv2d(16, 10, kernel_size=(1, 1), stride=(1, 1), bias=False)
)
)