Skip to content

Commit

Permalink
breastmnist fltlckks with compression done
Browse files Browse the repository at this point in the history
  • Loading branch information
AnasIshfaque committed May 26, 2024
1 parent 4a5be8f commit 2cc0352
Show file tree
Hide file tree
Showing 4 changed files with 389 additions and 207 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -28,7 +28,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -71,7 +71,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -81,7 +81,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -97,17 +97,9 @@
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cpu\n"
]
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# device = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu\")\n",
"device = \"cpu\"\n",
Expand Down Expand Up @@ -142,106 +134,17 @@
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"SqueezeNet(\n",
" (features): Sequential(\n",
" (0): Conv2d(3, 64, kernel_size=(3, 3), stride=(2, 2))\n",
" (1): ReLU(inplace=True)\n",
" (2): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=True)\n",
" (3): Fire(\n",
" (squeeze): Conv2d(64, 16, kernel_size=(1, 1), stride=(1, 1))\n",
" (squeeze_activation): ReLU(inplace=True)\n",
" (expand1x1): Conv2d(16, 64, kernel_size=(1, 1), stride=(1, 1))\n",
" (expand1x1_activation): ReLU(inplace=True)\n",
" (expand3x3): Conv2d(16, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n",
" (expand3x3_activation): ReLU(inplace=True)\n",
" )\n",
" (4): Fire(\n",
" (squeeze): Conv2d(128, 16, kernel_size=(1, 1), stride=(1, 1))\n",
" (squeeze_activation): ReLU(inplace=True)\n",
" (expand1x1): Conv2d(16, 64, kernel_size=(1, 1), stride=(1, 1))\n",
" (expand1x1_activation): ReLU(inplace=True)\n",
" (expand3x3): Conv2d(16, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n",
" (expand3x3_activation): ReLU(inplace=True)\n",
" )\n",
" (5): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=True)\n",
" (6): Fire(\n",
" (squeeze): Conv2d(128, 32, kernel_size=(1, 1), stride=(1, 1))\n",
" (squeeze_activation): ReLU(inplace=True)\n",
" (expand1x1): Conv2d(32, 128, kernel_size=(1, 1), stride=(1, 1))\n",
" (expand1x1_activation): ReLU(inplace=True)\n",
" (expand3x3): Conv2d(32, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n",
" (expand3x3_activation): ReLU(inplace=True)\n",
" )\n",
" (7): Fire(\n",
" (squeeze): Conv2d(256, 32, kernel_size=(1, 1), stride=(1, 1))\n",
" (squeeze_activation): ReLU(inplace=True)\n",
" (expand1x1): Conv2d(32, 128, kernel_size=(1, 1), stride=(1, 1))\n",
" (expand1x1_activation): ReLU(inplace=True)\n",
" (expand3x3): Conv2d(32, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n",
" (expand3x3_activation): ReLU(inplace=True)\n",
" )\n",
" (8): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=True)\n",
" (9): Fire(\n",
" (squeeze): Conv2d(256, 48, kernel_size=(1, 1), stride=(1, 1))\n",
" (squeeze_activation): ReLU(inplace=True)\n",
" (expand1x1): Conv2d(48, 192, kernel_size=(1, 1), stride=(1, 1))\n",
" (expand1x1_activation): ReLU(inplace=True)\n",
" (expand3x3): Conv2d(48, 192, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n",
" (expand3x3_activation): ReLU(inplace=True)\n",
" )\n",
" (10): Fire(\n",
" (squeeze): Conv2d(384, 48, kernel_size=(1, 1), stride=(1, 1))\n",
" (squeeze_activation): ReLU(inplace=True)\n",
" (expand1x1): Conv2d(48, 192, kernel_size=(1, 1), stride=(1, 1))\n",
" (expand1x1_activation): ReLU(inplace=True)\n",
" (expand3x3): Conv2d(48, 192, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n",
" (expand3x3_activation): ReLU(inplace=True)\n",
" )\n",
" (11): Fire(\n",
" (squeeze): Conv2d(384, 64, kernel_size=(1, 1), stride=(1, 1))\n",
" (squeeze_activation): ReLU(inplace=True)\n",
" (expand1x1): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1))\n",
" (expand1x1_activation): ReLU(inplace=True)\n",
" (expand3x3): Conv2d(64, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n",
" (expand3x3_activation): ReLU(inplace=True)\n",
" )\n",
" (12): Fire(\n",
" (squeeze): Conv2d(512, 64, kernel_size=(1, 1), stride=(1, 1))\n",
" (squeeze_activation): ReLU(inplace=True)\n",
" (expand1x1): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1))\n",
" (expand1x1_activation): ReLU(inplace=True)\n",
" (expand3x3): Conv2d(64, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n",
" (expand3x3_activation): ReLU(inplace=True)\n",
" )\n",
" )\n",
" (classifier): Sequential(\n",
" (0): Dropout(p=0.5, inplace=False)\n",
" (1): Conv2d(512, 1000, kernel_size=(1, 1), stride=(1, 1))\n",
" (2): ReLU(inplace=True)\n",
" (3): AdaptiveAvgPool2d(output_size=(1, 1))\n",
" )\n",
")"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sq_model = models.squeezenet1_1(weights=SqueezeNet1_1_Weights.DEFAULT)\n",
"sq_model.to(device)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -252,7 +155,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -275,7 +178,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -310,7 +213,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -341,7 +244,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -411,7 +314,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -452,7 +355,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -480,7 +383,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -522,7 +425,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -582,17 +485,9 @@
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"192.168.0.245\n"
]
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"host = socket.gethostbyname(socket.gethostname())\n",
"port = 10080\n",
Expand All @@ -601,7 +496,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -619,23 +514,9 @@
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"ename": "KeyboardInterrupt",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[18], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mrun_thread\u001b[49m\u001b[43m(\u001b[49m\u001b[43mreceive\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43musers\u001b[49m\u001b[43m)\u001b[49m\n",
"Cell \u001b[0;32mIn[13], line 7\u001b[0m, in \u001b[0;36mrun_thread\u001b[0;34m(func, num_user)\u001b[0m\n\u001b[1;32m 5\u001b[0m thrs \u001b[38;5;241m=\u001b[39m []\n\u001b[1;32m 6\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(num_user):\n\u001b[0;32m----> 7\u001b[0m conn, addr \u001b[38;5;241m=\u001b[39m \u001b[43ms\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43maccept\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 8\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mConntected with\u001b[39m\u001b[38;5;124m'\u001b[39m, addr)\n\u001b[1;32m 9\u001b[0m \u001b[38;5;66;03m# append client socket on list\u001b[39;00m\n",
"File \u001b[0;32m~/anaconda3/envs/pylinenv/lib/python3.10/socket.py:293\u001b[0m, in \u001b[0;36msocket.accept\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 286\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21maccept\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[1;32m 287\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"accept() -> (socket object, address info)\u001b[39;00m\n\u001b[1;32m 288\u001b[0m \n\u001b[1;32m 289\u001b[0m \u001b[38;5;124;03m Wait for an incoming connection. Return a new socket\u001b[39;00m\n\u001b[1;32m 290\u001b[0m \u001b[38;5;124;03m representing the connection, and the address of the client.\u001b[39;00m\n\u001b[1;32m 291\u001b[0m \u001b[38;5;124;03m For IP sockets, the address info is a pair (hostaddr, port).\u001b[39;00m\n\u001b[1;32m 292\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m--> 293\u001b[0m fd, addr \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_accept\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 294\u001b[0m sock \u001b[38;5;241m=\u001b[39m socket(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfamily, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtype, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mproto, fileno\u001b[38;5;241m=\u001b[39mfd)\n\u001b[1;32m 295\u001b[0m \u001b[38;5;66;03m# Issue #7995: if no default timeout is set and the listening\u001b[39;00m\n\u001b[1;32m 296\u001b[0m \u001b[38;5;66;03m# socket had a (non-zero) timeout, force the new socket in blocking\u001b[39;00m\n\u001b[1;32m 297\u001b[0m \u001b[38;5;66;03m# mode to override platform-specific socket flags inheritance.\u001b[39;00m\n",
"\u001b[0;31mKeyboardInterrupt\u001b[0m: "
]
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"run_thread(receive, users)"
]
Expand All @@ -649,8 +530,10 @@
"end_time = time.time() # store end time\n",
"print(\"TrainingTime: {} sec\".format(end_time - start_time))\n",
"print(\"Total aggrigation time: {} sec\".format(total_aggr_time))\n",
"print(\"Total send time: {} sec\".format(total_send_time)\n",
"print(\"Total recv time: {} sec\".format(total_recv_time)\n",
"print(\"Total compression time: {} sec\".format(total_compression_time))\n",
"print(\"Total decompression time: {} sec\".format(total_decompression_time))\n",
"print(\"Total send time: {} sec\".format(total_send_time))\n",
"print(\"Total recv time: {} sec\".format(total_recv_time))\n",
"print(\"Total communication time: {} sec\".format(total_send_time+total_recv_time))"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,8 @@ def recvall(sock, n):
print("Training Time: {} sec".format(end_time - start_time))
print(f'Total encryption time: {total_encrypt_time}')
print(f'Total decryption time: {total_decrypt_time}')
print(f'Total compression time: {total_compression_time}')
print(f'Total decompression time: {total_decompression_time}')
print(f'Total compression time: {total_compress_time}')
print(f'Total decompression time: {total_decompress_time}')
print(f'average sending speed: {sum(sending_speeds)/len(sending_speeds)}')
print(f'average receiving speed: {sum(receiving_speeds)/len(receiving_speeds)}')

Expand Down
Loading

0 comments on commit 2cc0352

Please sign in to comment.