Skip to content

Commit

Permalink
updated for arxiv
Browse files Browse the repository at this point in the history
  • Loading branch information
MDFahimAnjum committed Aug 19, 2024
1 parent 2592bf7 commit 9a61dc0
Show file tree
Hide file tree
Showing 29 changed files with 1,859 additions and 13 deletions.
72 changes: 72 additions & 0 deletions cnn_classifier.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,78 @@
"\n",
"print('Completed')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Model Details"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Model param total: 53142\n",
"CNN_Model(\n",
" (conv1): Conv1d(59, 5, kernel_size=(20,), stride=(1,))\n",
" (pool): AvgPool1d(kernel_size=(2,), stride=(2,), padding=(0,))\n",
" (conv2): Conv1d(5, 10, kernel_size=(10,), stride=(1,))\n",
" (conv3): Conv1d(10, 10, kernel_size=(10,), stride=(1,))\n",
" (conv4): Conv1d(10, 15, kernel_size=(5,), stride=(1,))\n",
" (fc1): Linear(in_features=2235, out_features=20, bias=True)\n",
" (fc2): Linear(in_features=20, out_features=10, bias=True)\n",
" (fc3): Linear(in_features=10, out_features=2, bias=True)\n",
" (dropout): Dropout(p=0.5, inplace=False)\n",
")\n",
"Output shape: torch.Size([1, 2])\n",
"----------------------------------------------------------------\n",
" Layer (type) Output Shape Param #\n",
"================================================================\n",
" Conv1d-1 [-1, 5, 2481] 5,905\n",
" AvgPool1d-2 [-1, 5, 1240] 0\n",
" Conv1d-3 [-1, 10, 1231] 510\n",
" AvgPool1d-4 [-1, 10, 615] 0\n",
" Conv1d-5 [-1, 10, 606] 1,010\n",
" AvgPool1d-6 [-1, 10, 303] 0\n",
" Conv1d-7 [-1, 15, 299] 765\n",
" AvgPool1d-8 [-1, 15, 149] 0\n",
" Dropout-9 [-1, 2235] 0\n",
" Linear-10 [-1, 20] 44,720\n",
" Dropout-11 [-1, 20] 0\n",
" Linear-12 [-1, 10] 210\n",
" Linear-13 [-1, 2] 22\n",
"================================================================\n",
"Total params: 53,142\n",
"Trainable params: 53,142\n",
"Non-trainable params: 0\n",
"----------------------------------------------------------------\n",
"Input size (MB): 0.56\n",
"Forward/backward pass size (MB): 0.42\n",
"Params size (MB): 0.20\n",
"Estimated Total Size (MB): 1.19\n",
"----------------------------------------------------------------\n"
]
}
],
"source": [
"from torchsummary import summary\n",
"\n",
"model_params = sum(p.numel() for p in model.parameters())\n",
"print(f'Model param total: {model_params}')\n",
"print(model)\n",
"\n",
"dummy_input = torch.randn(1, 59, 2500) # Batch size of 1\n",
"output = model(dummy_input)\n",
"print(f\"Output shape: {output.shape}\")\n",
"\n",
"summary(model, input_size=(59, 2500), device=device)"
]
}
],
"metadata": {
Expand Down
68 changes: 68 additions & 0 deletions crnn_classifier.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,74 @@
"\n",
"print('Completed')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Model Details"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Model param total: 23841\n",
"CRNN_Model(\n",
" (conv1): Conv1d(59, 32, kernel_size=(3,), stride=(1,))\n",
" (pool): MaxPool1d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
" (conv2): Conv1d(32, 64, kernel_size=(3,), stride=(1,))\n",
" (gru): GRU(64, 35, batch_first=True)\n",
" (time_distributed): Linear(in_features=35, out_features=35, bias=True)\n",
" (global_pool): AdaptiveAvgPool1d(output_size=1)\n",
" (fc): Linear(in_features=35, out_features=2, bias=True)\n",
" (dropout): Dropout(p=0.5, inplace=False)\n",
")\n",
"Output shape: torch.Size([1, 2])\n",
"----------------------------------------------------------------\n",
" Layer (type) Output Shape Param #\n",
"================================================================\n",
" Conv1d-1 [-1, 32, 2498] 5,696\n",
" MaxPool1d-2 [-1, 32, 1248] 0\n",
" Dropout-3 [-1, 32, 1248] 0\n",
" Conv1d-4 [-1, 64, 1246] 6,208\n",
" MaxPool1d-5 [-1, 64, 622] 0\n",
" Dropout-6 [-1, 64, 622] 0\n",
" GRU-7 [[-1, 622, 35], [-1, 2, 35]] 0\n",
" Linear-8 [-1, 622, 35] 1,260\n",
" AdaptiveAvgPool1d-9 [-1, 35, 1] 0\n",
" Linear-10 [-1, 2] 72\n",
"================================================================\n",
"Total params: 13,236\n",
"Trainable params: 13,236\n",
"Non-trainable params: 0\n",
"----------------------------------------------------------------\n",
"Input size (MB): 0.56\n",
"Forward/backward pass size (MB): 9.03\n",
"Params size (MB): 0.05\n",
"Estimated Total Size (MB): 9.64\n",
"----------------------------------------------------------------\n"
]
}
],
"source": [
"from torchsummary import summary\n",
"\n",
"model_params = sum(p.numel() for p in model.parameters())\n",
"print(f'Model param total: {model_params}')\n",
"print(model)\n",
"\n",
"dummy_input = torch.randn(1, 59, 2500) # Batch size of 1\n",
"output = model(dummy_input)\n",
"print(f\"Output shape: {output.shape}\")\n",
"\n",
"summary(model, input_size=(59, 2500), device=device)"
]
}
],
"metadata": {
Expand Down
86 changes: 86 additions & 0 deletions deepnet_classifier.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,92 @@
"\n",
"print('Completed')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Model Details"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Model param total: 311177\n",
"DeepConvNet(\n",
" (conv1_1): Conv2d(1, 25, kernel_size=(1, 10), stride=(1, 1))\n",
" (conv1_2): Conv2d(25, 25, kernel_size=(59, 1), stride=(1, 1))\n",
" (batchnorm1): BatchNorm2d(25, eps=1e-05, momentum=0.9, affine=True, track_running_stats=True)\n",
" (pool1): MaxPool2d(kernel_size=(1, 3), stride=(1, 3), padding=0, dilation=1, ceil_mode=False)\n",
" (dropout1): Dropout(p=0.5, inplace=False)\n",
" (conv2): Conv2d(25, 50, kernel_size=(1, 10), stride=(1, 1))\n",
" (batchnorm2): BatchNorm2d(50, eps=1e-05, momentum=0.9, affine=True, track_running_stats=True)\n",
" (pool2): MaxPool2d(kernel_size=(1, 3), stride=(1, 3), padding=0, dilation=1, ceil_mode=False)\n",
" (dropout2): Dropout(p=0.5, inplace=False)\n",
" (conv3): Conv2d(50, 100, kernel_size=(1, 10), stride=(1, 1))\n",
" (batchnorm3): BatchNorm2d(100, eps=1e-05, momentum=0.9, affine=True, track_running_stats=True)\n",
" (pool3): MaxPool2d(kernel_size=(1, 3), stride=(1, 3), padding=0, dilation=1, ceil_mode=False)\n",
" (dropout3): Dropout(p=0.5, inplace=False)\n",
" (conv4): Conv2d(100, 200, kernel_size=(1, 10), stride=(1, 1))\n",
" (batchnorm4): BatchNorm2d(200, eps=1e-05, momentum=0.9, affine=True, track_running_stats=True)\n",
" (pool4): MaxPool2d(kernel_size=(1, 3), stride=(1, 3), padding=0, dilation=1, ceil_mode=False)\n",
" (dropout4): Dropout(p=0.5, inplace=False)\n",
" (fc): Linear(in_features=5200, out_features=2, bias=True)\n",
")\n",
"Output shape: torch.Size([1, 2])\n",
"----------------------------------------------------------------\n",
" Layer (type) Output Shape Param #\n",
"================================================================\n",
" Conv2d-1 [-1, 25, 59, 2491] 275\n",
" Conv2d-2 [-1, 25, 1, 2491] 36,900\n",
" BatchNorm2d-3 [-1, 25, 1, 2491] 50\n",
" MaxPool2d-4 [-1, 25, 1, 830] 0\n",
" Dropout-5 [-1, 25, 1, 830] 0\n",
" Conv2d-6 [-1, 50, 1, 821] 12,550\n",
" BatchNorm2d-7 [-1, 50, 1, 821] 100\n",
" MaxPool2d-8 [-1, 50, 1, 273] 0\n",
" Dropout-9 [-1, 50, 1, 273] 0\n",
" Conv2d-10 [-1, 100, 1, 264] 50,100\n",
" BatchNorm2d-11 [-1, 100, 1, 264] 200\n",
" MaxPool2d-12 [-1, 100, 1, 88] 0\n",
" Dropout-13 [-1, 100, 1, 88] 0\n",
" Conv2d-14 [-1, 200, 1, 79] 200,200\n",
" BatchNorm2d-15 [-1, 200, 1, 79] 400\n",
" MaxPool2d-16 [-1, 200, 1, 26] 0\n",
" Dropout-17 [-1, 200, 1, 26] 0\n",
" Linear-18 [-1, 2] 10,402\n",
"================================================================\n",
"Total params: 311,177\n",
"Trainable params: 311,177\n",
"Non-trainable params: 0\n",
"----------------------------------------------------------------\n",
"Input size (MB): 0.56\n",
"Forward/backward pass size (MB): 30.99\n",
"Params size (MB): 1.19\n",
"Estimated Total Size (MB): 32.74\n",
"----------------------------------------------------------------\n"
]
}
],
"source": [
"from torchsummary import summary\n",
"\n",
"model_params = sum(p.numel() for p in model.parameters())\n",
"print(f'Model param total: {model_params}')\n",
"print(model)\n",
"\n",
"dummy_input = torch.randn(1, 59, 2500) # Batch size of 1\n",
"output = model(dummy_input)\n",
"print(f\"Output shape: {output.shape}\")\n",
"\n",
"summary(model, input_size=(59, 2500), device=device)"
]
}
],
"metadata": {
Expand Down
90 changes: 90 additions & 0 deletions eegnet_classifier.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,96 @@
"\n",
"print('Completed')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Model Details"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Model param total: 4290\n",
"EEGNet(\n",
" (conv1): Conv2d(1, 8, kernel_size=(1, 32), stride=(1, 1), padding=same, bias=False)\n",
" (batchnorm1): BatchNorm2d(8, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
" (depthwise_conv): Conv2d(8, 16, kernel_size=(59, 1), stride=(1, 1), padding=valid, groups=8, bias=False)\n",
" (batchnorm2): BatchNorm2d(16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
" (elu1): ELU(alpha=1.0)\n",
" (avgpool1): AvgPool2d(kernel_size=(1, 4), stride=(1, 4), padding=0)\n",
" (dropout1): Dropout(p=0.5, inplace=False)\n",
" (separable_conv): Sequential(\n",
" (0): Conv2d(16, 16, kernel_size=(1, 16), stride=(1, 1), padding=same, groups=16, bias=False)\n",
" (1): Conv2d(16, 16, kernel_size=(1, 1), stride=(1, 1), bias=False)\n",
" )\n",
" (batchnorm3): BatchNorm2d(16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)\n",
" (elu2): ELU(alpha=1.0)\n",
" (avgpool2): AvgPool2d(kernel_size=(1, 8), stride=(1, 8), padding=0)\n",
" (dropout2): Dropout(p=0.5, inplace=False)\n",
" (flatten): Flatten(start_dim=1, end_dim=-1)\n",
" (dense): Linear(in_features=1248, out_features=2, bias=True)\n",
")\n",
"Output shape: torch.Size([1, 2])\n",
"----------------------------------------------------------------\n",
" Layer (type) Output Shape Param #\n",
"================================================================\n",
" Conv2d-1 [-1, 8, 59, 2500] 256\n",
" BatchNorm2d-2 [-1, 8, 59, 2500] 16\n",
" Conv2d-3 [-1, 16, 1, 2500] 944\n",
" BatchNorm2d-4 [-1, 16, 1, 2500] 32\n",
" ELU-5 [-1, 16, 1, 2500] 0\n",
" AvgPool2d-6 [-1, 16, 1, 625] 0\n",
" Dropout-7 [-1, 16, 1, 625] 0\n",
" Conv2d-8 [-1, 16, 1, 625] 256\n",
" Conv2d-9 [-1, 16, 1, 625] 256\n",
" BatchNorm2d-10 [-1, 16, 1, 625] 32\n",
" ELU-11 [-1, 16, 1, 625] 0\n",
" AvgPool2d-12 [-1, 16, 1, 78] 0\n",
" Dropout-13 [-1, 16, 1, 78] 0\n",
" Flatten-14 [-1, 1248] 0\n",
" Linear-15 [-1, 2] 2,498\n",
"================================================================\n",
"Total params: 4,290\n",
"Trainable params: 4,290\n",
"Non-trainable params: 0\n",
"----------------------------------------------------------------\n",
"Input size (MB): 0.56\n",
"Forward/backward pass size (MB): 19.41\n",
"Params size (MB): 0.02\n",
"Estimated Total Size (MB): 19.99\n",
"----------------------------------------------------------------\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"c:\\Users\\fahim\\anaconda3\\envs\\mybertV2\\lib\\site-packages\\torch\\nn\\modules\\conv.py:456: UserWarning: Using padding='same' with even kernel lengths and odd dilation may require a zero-padded copy of the input be created (Triggered internally at C:\\cb\\pytorch_1000000000000\\work\\aten\\src\\ATen\\native\\Convolution.cpp:1041.)\n",
" return F.conv2d(input, weight, bias, self.stride,\n"
]
}
],
"source": [
"from torchsummary import summary\n",
"\n",
"model_params = sum(p.numel() for p in model.parameters())\n",
"print(f'Model param total: {model_params}')\n",
"print(model)\n",
"\n",
"dummy_input = torch.randn(1, 59, 2500) # Batch size of 1\n",
"output = model(dummy_input)\n",
"print(f\"Output shape: {output.shape}\")\n",
"\n",
"summary(model, input_size=(59, 2500), device=device)"
]
}
],
"metadata": {
Expand Down
Loading

0 comments on commit 9a61dc0

Please sign in to comment.