Skip to content

Commit

Permalink
Fixing the PoisoningAttackDemo.ipynb notebook
Browse files Browse the repository at this point in the history
Signed-off-by: Teodor Parvanov <[email protected]>
  • Loading branch information
teoparvanov committed Jan 20, 2025
1 parent 61a28be commit d5d86d7
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,8 @@
" state_dicts = [model.state_dict() for model in models]\n",
" state_dict = new_model.state_dict()\n",
" for key in models[1].state_dict():\n",
" state_dict[key] = np.sum(\n",
" [state[key] for state in state_dicts], axis=0\n",
" ) / len(models)\n",
" state_dict[key] = torch.from_numpy(\n",
" np.average([state[key].numpy() for state in state_dicts], axis=0))\n",
" new_model.load_state_dict(state_dict)\n",
" return new_model\n",
"\n",
Expand Down Expand Up @@ -558,8 +557,7 @@
" exclude=[\"private\"],\n",
" )\n",
"\n",
" # @collaborator # Uncomment if you want ro run on CPU\n",
" @collaborator(num_gpus=1) # Assuming GPU(s) is available on the machine\n",
" @collaborator\n",
" def train(self):\n",
" self.collaborator_name = self.input\n",
" print(20 * \"#\")\n",
Expand Down Expand Up @@ -669,7 +667,7 @@
"\n",
" ac_e = AgglomerativeClustering(n_clusters=2, distance_threshold=None,\n",
" compute_full_tree=True,\n",
" affinity=\"euclidean\", memory=None, connectivity=None,\n",
" metric=\"euclidean\", memory=None, connectivity=None,\n",
" linkage='single',\n",
" compute_distances=True).fit(binary_votes)\n",
" ac_e_labels: list = ac_e.labels_.tolist()\n",
Expand Down

0 comments on commit d5d86d7

Please sign in to comment.