Repository navigation
Description
I found a few bugs in the implementation of eegnex:
-
Activation is missing at two positions (between BN and pooling):
braindecode/braindecode/models/eegnex.py
Lines 151 to 152 in 050ceea
nn.BatchNorm2d(num_features=self.filter_3), nn.AvgPool2d(
braindecode/braindecode/models/eegnex.py
Lines 181 to 182 in 050ceea
nn.BatchNorm2d(num_features=self.filter_1), nn.AvgPool2d( -
Maximum norm constraint is missing at two positions:
- should be 1 here:
braindecode/braindecode/models/eegnex.py
Lines 143 to 150 in 050ceea
nn.Conv2d( in_channels=self.filter_2, out_channels=self.filter_3, kernel_size=(self.n_chans, 1), groups=self.filter_2, padding=(0, 0), bias=False, ), - should be 0.25 here:
braindecode/braindecode/models/eegnex.py
Lines 191 to 193 in 050ceea
self.final_layer = nn.Linear( in_features=self.in_features, out_features=self.n_outputs )
- I am not sure about the activation in line 128, from the paper it should be after line 139.
braindecode/braindecode/models/eegnex.py
Lines 128 to 140 in 050ceea
self.activation(), ) self.block_2 = nn.Sequential( nn.Conv2d( in_channels=self.filter_1, out_channels=self.filter_2, kernel_size=(1, 64), padding="same", bias=False, ), nn.BatchNorm2d(num_features=self.filter_2), )
The official code is consitent with braindecode but not with the paper:
https://github.com/chenxiachan/EEGNeX/blob/044d7fb2a5b953c7004f30fe45db40d1ce57af5c/BenchmarkModels.py#L610-L612
Further suggestions:
-
These could be integers:
braindecode/braindecode/models/eegnex.py
Lines 76 to 81 in 050ceea
kernel_block_4: tuple[int, int] = (1, 16), dilation_block_4: tuple[int, int] = (1, 2), avg_pool_block4: tuple[int, int] = (1, 4), kernel_block_5: tuple[int, int] = (1, 16), dilation_block_5: tuple[int, int] = (1, 4), avg_pool_block5: tuple[int, int] = (1, 8), -
This function could be private:
braindecode/braindecode/models/eegnex.py
Lines 224 to 227 in 050ceea
@staticmethod def calc_padding( kernel_size: tuple[int, int], dilation: tuple[int, int] ) -> tuple[int, int]: -
Reduce verbosity by using default values here
braindecode/braindecode/models/eegnex.py
Line 148 in 050ceea
padding=(0, 0), braindecode/braindecode/models/eegnex.py
Line 154 in 050ceea
stride=self.avg_pool_block4, braindecode/braindecode/models/eegnex.py
Line 184 in 050ceea
stride=self.avg_pool_block5,
Activity