braindecode 1.2.0.dev169062562__py3-none-any.whl → 1.2.0.dev176358851__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of braindecode might be problematic. Click here for more details.
- braindecode/models/eegconformer.py +111 -15
- braindecode/models/eegnet.py +54 -4
- braindecode/modules/attention.py +6 -3
- braindecode/modules/convolution.py +10 -7
- braindecode/modules/filter.py +8 -6
- braindecode/training/scoring.py +2 -8
- braindecode/version.py +1 -1
- braindecode/visualization/gradients.py +6 -1
- {braindecode-1.2.0.dev169062562.dist-info → braindecode-1.2.0.dev176358851.dist-info}/METADATA +1 -1
- {braindecode-1.2.0.dev169062562.dist-info → braindecode-1.2.0.dev176358851.dist-info}/RECORD +14 -14
- {braindecode-1.2.0.dev169062562.dist-info → braindecode-1.2.0.dev176358851.dist-info}/WHEEL +0 -0
- {braindecode-1.2.0.dev169062562.dist-info → braindecode-1.2.0.dev176358851.dist-info}/licenses/LICENSE.txt +0 -0
- {braindecode-1.2.0.dev169062562.dist-info → braindecode-1.2.0.dev176358851.dist-info}/licenses/NOTICE.txt +0 -0
- {braindecode-1.2.0.dev169062562.dist-info → braindecode-1.2.0.dev176358851.dist-info}/top_level.txt +0 -0
|
@@ -12,33 +12,126 @@ from braindecode.modules import FeedForwardBlock, MultiHeadAttention
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class EEGConformer(EEGModuleMixin, nn.Module):
|
|
15
|
-
"""EEG Conformer from Song et al. (2022)
|
|
15
|
+
"""EEG Conformer from Song et al. (2022) [song2022]_.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
:bdg-success:`Convolution` :bdg-info:`Small Attention`
|
|
18
|
+
|
|
19
|
+
.. figure:: https://raw.githubusercontent.com/eeyhsong/EEG-Conformer/refs/heads/main/visualization/Fig1.png
|
|
18
20
|
:align: center
|
|
19
21
|
:alt: EEGConformer Architecture
|
|
22
|
+
:width: 600px
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
.. rubric:: Architectural Overview
|
|
26
|
+
|
|
27
|
+
EEG-Conformer is a *convolution-first* model augmented with a *lightweight transformer
|
|
28
|
+
encoder*. The end-to-end flow is:
|
|
29
|
+
|
|
30
|
+
- (i) :class:`_PatchEmbedding` converts the continuous EEG into a compact sequence of tokens via a :class:`ShallowFBCSPNet` temporal–spatial conv stem and temporal pooling;
|
|
31
|
+
- (ii) :class:`_TransformerEncoder applies small multi-head self-attention to integrate longer-range temporal context across tokens;
|
|
32
|
+
- (iii) :class:`_ClassificationHead` aggregates the sequence and performs a linear readout.
|
|
33
|
+
This preserves the strong inductive biases of shallow CNN filter banks while adding
|
|
34
|
+
just enough attention to capture dependencies beyond the pooling horizon [song2022]_.
|
|
35
|
+
|
|
36
|
+
.. rubric:: Macro Components
|
|
37
|
+
|
|
38
|
+
- :class:`_PatchEmbedding` **(Shallow conv stem → tokens)**
|
|
39
|
+
|
|
40
|
+
- *Operations.*
|
|
41
|
+
- A temporal convolution (`:class:`torch.nn.Conv2d`) ``(1 x L_t)`` forms a data-driven "filter bank";
|
|
42
|
+
- A spatial convolution (`:class:`torch.nn.Conv2d`) (n_chans x 1)`` projects across electrodes, collapsing the channel axis into a virtual channel.
|
|
43
|
+
- **Normalization function** `:class:torch.nn.BatchNorm`
|
|
44
|
+
- **Activation function** `:class:torch.nn.ELU`
|
|
45
|
+
- **Average Pooling** `:class:torch.nn.AvgPool` along time (kernel ``(1, P)`` with stride ``(1, S)``)
|
|
46
|
+
- final ``1x1`` :class:`torch.nn.Linear` projection.
|
|
47
|
+
|
|
48
|
+
The result is rearranged to a token sequence ``(B, S_tokens, D)``, where ``D = n_filters_time``.
|
|
49
|
+
|
|
50
|
+
*Interpretability/robustness.* Temporal kernels can be inspected as FIR filters;
|
|
51
|
+
the spatial conv yields channel projections analogous to :class:`ShallowFBCSPNet`’s learned
|
|
52
|
+
spatial filters. Temporal pooling stabilizes statistics and reduces sequence length.
|
|
53
|
+
|
|
54
|
+
- :class:`_TransformerEncoder` **(context over temporal tokens)**
|
|
55
|
+
|
|
56
|
+
- *Operations.*
|
|
57
|
+
- A stack of ``att_depth`` encoder blocks. :class:`_TransformerEncoderBlock`
|
|
58
|
+
- Each block applies LayerNorm :class:`torch.nn.LayerNorm`
|
|
59
|
+
- Multi-Head Self-Attention (``att_heads``) with dropout + residual :class:`MultiHeadAttention` (:class:`torch.nn.Dropout`)
|
|
60
|
+
- LayerNorm :class:`torch.nn.LayerNorm`
|
|
61
|
+
- 2-layer feed-forward (≈4x expansion, :class:`torch.nn.GELU`) with dropout + residual.
|
|
62
|
+
|
|
63
|
+
Shapes remain ``(B, S_tokens, D)`` throughout.
|
|
20
64
|
|
|
21
|
-
|
|
65
|
+
*Role.* Small attention focuses on interactions among *temporal patches* (not channels),
|
|
66
|
+
extending effective receptive fields at modest cost.
|
|
22
67
|
|
|
23
|
-
|
|
24
|
-
choices are available at the [song2022]_ and [ConformerCode]_.
|
|
68
|
+
- :class:`ClassificationHead` **(aggregation + readout)**
|
|
25
69
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
70
|
+
- *Operations*.
|
|
71
|
+
- Flatten, :class:`torch.nn.Flatten` the sequence ``(B, S_tokens·D)`` -
|
|
72
|
+
- MLP (:class:`torch.nn.Linear` → activation (default: :class:`torch.nn.ELU`) → :class:`torch.nn.Dropout` → :class:`torch.nn.Linear`)
|
|
73
|
+
- final Linear to classes.
|
|
29
74
|
|
|
30
|
-
|
|
75
|
+
With ``return_features=True``, features before the last Linear can be exported for
|
|
76
|
+
linear probing or downstream tasks.
|
|
31
77
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
78
|
+
.. rubric:: Convolutional Details
|
|
79
|
+
|
|
80
|
+
- **Temporal (where time-domain patterns are learned).**
|
|
81
|
+
The initial ``(1 x L_t)`` conv per channel acts as a *learned filter bank* for oscillatory
|
|
82
|
+
bands and transients. Subsequent **AvgPool** along time performs local integration,
|
|
83
|
+
converting activations into “patches” (tokens). Pool length/stride control the
|
|
84
|
+
token rate and set the lower bound on temporal context within each token.
|
|
85
|
+
|
|
86
|
+
- **Spatial (how electrodes are processed).**
|
|
87
|
+
A single conv with kernel ``(n_chans x 1)`` spans the full montage to learn spatial
|
|
88
|
+
projections for each temporal feature map, collapsing the channel axis into a
|
|
89
|
+
virtual channel before tokenization. This mirrors the shallow spatial step in
|
|
90
|
+
:class:`ShallowFBCSPNet` (temporal filters → spatial projection → temporal condensation).
|
|
91
|
+
|
|
92
|
+
- **Spectral (how frequency content is captured).**
|
|
93
|
+
No explicit Fourier/wavelet stage is used. Spectral selectivity emerges implicitly
|
|
94
|
+
from the learned temporal kernels; pooling further smooths high-frequency noise.
|
|
95
|
+
The effective spectral resolution is thus governed by ``L_t`` and the pooling
|
|
96
|
+
configuration.
|
|
97
|
+
|
|
98
|
+
.. rubric:: Attention / Sequential Modules
|
|
99
|
+
|
|
100
|
+
- **Type.** Standard multi-head self-attention (MHA) with ``att_heads`` heads over the token sequence.
|
|
101
|
+
- **Shapes.** Input/Output: ``(B, S_tokens, D)``; attention operates along the ``S_tokens`` axis.
|
|
102
|
+
- **Role.** Re-weights and integrates evidence across pooled windows, capturing dependencies
|
|
103
|
+
longer than any single token while leaving channel relationships to the convolutional stem.
|
|
104
|
+
The design is intentionally *small*—attention refines rather than replaces convolutional feature extraction.
|
|
105
|
+
|
|
106
|
+
.. rubric:: Additional Mechanisms
|
|
107
|
+
|
|
108
|
+
- **Parallel with ShallowFBCSPNet.** Both begin with a learned temporal filter bank,
|
|
109
|
+
spatial projection across electrodes, and early temporal condensation.
|
|
110
|
+
:class:`ShallowFBCSPNet` then computes band-power (via squaring/log-variance), whereas
|
|
111
|
+
EEG-Conformer applies BN/ELU and **continues with attention** over tokens to
|
|
112
|
+
refine temporal context before classification.
|
|
113
|
+
|
|
114
|
+
- **Tokenization knob.** ``pool_time_length`` and especially ``pool_time_stride`` set
|
|
115
|
+
the number of tokens ``S_tokens``. Smaller strides → more tokens and higher attention
|
|
116
|
+
capacity (but higher compute); larger strides → fewer tokens and stronger inductive bias.
|
|
117
|
+
|
|
118
|
+
- **Embedding dimension = filters.** ``n_filters_time`` serves double duty as both the
|
|
119
|
+
number of temporal filters in the stem and the transformer’s embedding size ``D``,
|
|
120
|
+
simplifying dimensional alignment.
|
|
121
|
+
|
|
122
|
+
.. rubric:: Usage and Configuration
|
|
123
|
+
|
|
124
|
+
- **Instantiation.** Choose ``n_filters_time`` (embedding size ``D``) and
|
|
125
|
+
``filter_time_length`` to match the rhythms of interest. Tune
|
|
126
|
+
``pool_time_length/stride`` to trade temporal resolution for sequence length.
|
|
127
|
+
Keep ``att_depth`` modest (e.g., 4–6) and set ``att_heads`` to divide ``D``.
|
|
128
|
+
``final_fc_length="auto"`` infers the flattened size from PatchEmbedding.
|
|
36
129
|
|
|
37
130
|
Notes
|
|
38
131
|
-----
|
|
39
132
|
The authors recommend using data augmentation before using Conformer,
|
|
40
133
|
e.g. segmentation and recombination,
|
|
41
|
-
Please refer to the original paper and code for more details.
|
|
134
|
+
Please refer to the original paper and code for more details [ConformerCode]_.
|
|
42
135
|
|
|
43
136
|
The model was initially tuned on 4 seconds of 250 Hz data.
|
|
44
137
|
Please adjust the scale of the temporal convolutional layer,
|
|
@@ -47,7 +140,10 @@ class EEGConformer(EEGModuleMixin, nn.Module):
|
|
|
47
140
|
.. versionadded:: 0.8
|
|
48
141
|
|
|
49
142
|
We aggregate the parameters based on the parts of the models, or
|
|
50
|
-
when the parameters were used first, e.g. n_filters_time
|
|
143
|
+
when the parameters were used first, e.g. ``n_filters_time``.
|
|
144
|
+
|
|
145
|
+
.. versionadded:: 1.1
|
|
146
|
+
|
|
51
147
|
|
|
52
148
|
Parameters
|
|
53
149
|
----------
|
braindecode/models/eegnet.py
CHANGED
|
@@ -20,13 +20,60 @@ from braindecode.modules import (
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
class EEGNetv4(EEGModuleMixin, nn.Sequential):
|
|
23
|
-
"""EEGNet v4 model from Lawhern et al. (2018) [
|
|
23
|
+
"""EEGNet v4 model from Lawhern et al. (2018) [Lawhern2018]_.
|
|
24
|
+
|
|
25
|
+
:bdg-success:`Convolution` :bdg-secondary:`Depthwise–Separable`
|
|
24
26
|
|
|
25
27
|
.. figure:: https://content.cld.iop.org/journals/1741-2552/15/5/056013/revision2/jneaace8cf01_hr.jpg
|
|
26
28
|
:align: center
|
|
27
|
-
:alt:
|
|
29
|
+
:alt: EEGNetv4 Architecture
|
|
30
|
+
:width: 600px
|
|
31
|
+
|
|
32
|
+
.. rubric:: Architectural Overview
|
|
33
|
+
|
|
34
|
+
EEGNetv4 is a compact convolutional network designed for EEG decoding with a
|
|
35
|
+
pipeline that mirrors classical EEG processing:
|
|
36
|
+
- (i) learn temporal frequency-selective filters,
|
|
37
|
+
- (ii) learn spatial filters for those frequencies, and
|
|
38
|
+
- (iii) condense features with depthwise–separable convolutions before a lightweight classifier.
|
|
39
|
+
|
|
40
|
+
The architecture is deliberately small (temporal convolutional and spatial patterns) [Lawhern2018]_.
|
|
41
|
+
|
|
42
|
+
.. rubric:: Macro Components
|
|
43
|
+
|
|
44
|
+
- **Temporal convolution**
|
|
45
|
+
Temporal convolution applied per channel; learns ``F1`` kernels that act as data-driven band-pass filters.
|
|
46
|
+
- **Depthwise Spatial Filtering.**
|
|
47
|
+
Depthwise convolution spanning the channel dimension with ``groups = F1``,
|
|
48
|
+
yielding ``D`` spatial filters for each temporal filter (no cross-filter mixing).
|
|
49
|
+
- **Norm–Nonlinearity–Pooling (+ dropout).**
|
|
50
|
+
Batch normalization → ELU → temporal pooling, with dropout.
|
|
51
|
+
- **Depthwise–Separable Convolution Block.**
|
|
52
|
+
(a) depthwise temporal conv to refine temporal structure;
|
|
53
|
+
(b) pointwise 1x1 conv to mix feature maps into ``F2`` combinations.
|
|
54
|
+
- **Classifier Head.**
|
|
55
|
+
Lightweight 1x1 conv or dense layer (often with max-norm constraint).
|
|
28
56
|
|
|
29
|
-
|
|
57
|
+
.. rubric:: Convolutional Details
|
|
58
|
+
|
|
59
|
+
**Temporal.** The initial temporal convs serve as a *learned filter bank*:
|
|
60
|
+
long 1-D kernels (implemented as 2-D with singleton spatial extent) emphasize oscillatory bands and transients.
|
|
61
|
+
Because this stage is linear prior to BN/ELU, kernels can be analyzed as FIR filters to reveal each feature’s spectrum [Lawhern2018]_.
|
|
62
|
+
|
|
63
|
+
**Spatial.** The depthwise spatial conv spans the full channel axis (kernel height = #electrodes; temporal size = 1).
|
|
64
|
+
With ``groups = F1``, each temporal filter learns its own set of ``D`` spatial projections—akin to CSP, learned end-to-end and
|
|
65
|
+
typically regularized with max-norm.
|
|
66
|
+
|
|
67
|
+
**Spectral.** No explicit Fourier/wavelet transform is used. Frequency structure
|
|
68
|
+
is captured implicitly by the temporal filter bank; later depthwise temporal kernels act as short-time integrators/refiners.
|
|
69
|
+
|
|
70
|
+
.. rubric:: Additional Comments
|
|
71
|
+
|
|
72
|
+
- **Filter-bank structure:** Parallel temporal kernels (``F1``) emulate classical filter banks; pairing them with frequency-specific spatial filters
|
|
73
|
+
yields features mappable to rhythms and topographies.
|
|
74
|
+
- **Depthwise & separable convs:** Parameter-efficient decomposition (depthwise + pointwise) retains power while limiting overfitting
|
|
75
|
+
[Chollet2017]_ and keeps temporal vs. mixing steps interpretable.
|
|
76
|
+
- **Regularization:** Batch norm, dropout, pooling, and optional max-norm on spatial kernels aid stability on small EEG datasets.
|
|
30
77
|
|
|
31
78
|
Parameters
|
|
32
79
|
----------
|
|
@@ -68,10 +115,13 @@ class EEGNetv4(EEGModuleMixin, nn.Sequential):
|
|
|
68
115
|
|
|
69
116
|
References
|
|
70
117
|
----------
|
|
71
|
-
.. [
|
|
118
|
+
.. [Lawhern2018] Lawhern, V. J., Solon, A. J., Waytowich, N. R., Gordon, S. M.,
|
|
72
119
|
Hung, C. P., & Lance, B. J. (2018). EEGNet: a compact convolutional
|
|
73
120
|
neural network for EEG-based brain–computer interfaces. Journal of
|
|
74
121
|
neural engineering, 15(5), 056013.
|
|
122
|
+
.. [Chollet2017] Chollet, F., *Xception: Deep Learning with Depthwise Separable
|
|
123
|
+
Convolutions*, CVPR, 2017.
|
|
124
|
+
|
|
75
125
|
"""
|
|
76
126
|
|
|
77
127
|
def __init__(
|
braindecode/modules/attention.py
CHANGED
|
@@ -157,7 +157,8 @@ class FCA(nn.Module):
|
|
|
157
157
|
):
|
|
158
158
|
super(FCA, self).__init__()
|
|
159
159
|
mapper_y = [freq_idx]
|
|
160
|
-
|
|
160
|
+
if in_channels % len(mapper_y) != 0:
|
|
161
|
+
raise ValueError("in_channels must be divisible by number of DCT filters")
|
|
161
162
|
|
|
162
163
|
self.weight = nn.Parameter(
|
|
163
164
|
self.get_dct_filter(seq_len, mapper_y, in_channels), requires_grad=False
|
|
@@ -295,7 +296,8 @@ class ECA(nn.Module):
|
|
|
295
296
|
def __init__(self, in_channels: int, kernel_size: int):
|
|
296
297
|
super(ECA, self).__init__()
|
|
297
298
|
self.gap = nn.AdaptiveAvgPool2d(1)
|
|
298
|
-
|
|
299
|
+
if kernel_size % 2 != 1:
|
|
300
|
+
raise ValueError("kernel size must be odd for same padding")
|
|
299
301
|
self.conv = nn.Conv1d(
|
|
300
302
|
1, 1, kernel_size=kernel_size, padding=kernel_size // 2, bias=False
|
|
301
303
|
)
|
|
@@ -530,7 +532,8 @@ class CBAM(nn.Module):
|
|
|
530
532
|
nn.ReLU(),
|
|
531
533
|
nn.Conv2d(in_channels // reduction_rate, in_channels, 1, bias=False),
|
|
532
534
|
)
|
|
533
|
-
|
|
535
|
+
if kernel_size % 2 != 1:
|
|
536
|
+
raise ValueError("kernel size must be odd for same padding")
|
|
534
537
|
self.conv = nn.Conv2d(2, 1, (1, kernel_size), padding=(0, kernel_size // 2))
|
|
535
538
|
|
|
536
539
|
def forward(self, x):
|
|
@@ -136,7 +136,8 @@ class CombinedConv(nn.Module):
|
|
|
136
136
|
# Calculate bias terms
|
|
137
137
|
if self.bias_time:
|
|
138
138
|
time_bias = self.conv_time.bias
|
|
139
|
-
|
|
139
|
+
if time_bias is None:
|
|
140
|
+
raise RuntimeError("conv_time.bias is None despite bias_time=True")
|
|
140
141
|
calculated_bias = (
|
|
141
142
|
self.conv_spat.weight.squeeze()
|
|
142
143
|
.sum(-1)
|
|
@@ -145,7 +146,8 @@ class CombinedConv(nn.Module):
|
|
|
145
146
|
)
|
|
146
147
|
if self.bias_spat:
|
|
147
148
|
spat_bias = self.conv_spat.bias
|
|
148
|
-
|
|
149
|
+
if spat_bias is None:
|
|
150
|
+
raise RuntimeError("conv_spat.bias is None despite bias_spat=True")
|
|
149
151
|
if calculated_bias is None:
|
|
150
152
|
calculated_bias = spat_bias
|
|
151
153
|
else:
|
|
@@ -190,11 +192,12 @@ class CausalConv1d(nn.Conv1d):
|
|
|
190
192
|
dilation=1,
|
|
191
193
|
**kwargs,
|
|
192
194
|
):
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
195
|
+
if "padding" in kwargs:
|
|
196
|
+
raise ValueError(
|
|
197
|
+
"The padding parameter is controlled internally by "
|
|
198
|
+
f"{type(self).__name__} class. You should not try to override this"
|
|
199
|
+
" parameter."
|
|
200
|
+
)
|
|
198
201
|
|
|
199
202
|
super().__init__(
|
|
200
203
|
in_channels=in_channels,
|
braindecode/modules/filter.py
CHANGED
|
@@ -452,12 +452,14 @@ class GeneralizedGaussianFilter(nn.Module):
|
|
|
452
452
|
self.inverse_fourier = inverse_fourier
|
|
453
453
|
self.affine_group_delay = affine_group_delay
|
|
454
454
|
self.clamp_f_mean = clamp_f_mean
|
|
455
|
-
|
|
456
|
-
"out_channels has to be multiple of in_channels"
|
|
457
|
-
)
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
455
|
+
if out_channels % in_channels != 0:
|
|
456
|
+
raise ValueError("out_channels has to be multiple of in_channels")
|
|
457
|
+
if len(f_mean) * in_channels != out_channels:
|
|
458
|
+
raise ValueError("len(f_mean) * in_channels must equal out_channels")
|
|
459
|
+
if len(bandwidth) * in_channels != out_channels:
|
|
460
|
+
raise ValueError("len(bandwidth) * in_channels must equal out_channels")
|
|
461
|
+
if len(shape) * in_channels != out_channels:
|
|
462
|
+
raise ValueError("len(shape) * in_channels must equal out_channels")
|
|
461
463
|
|
|
462
464
|
# Range from 0 to half sample rate, normalized
|
|
463
465
|
self.n_range = nn.Parameter(
|
braindecode/training/scoring.py
CHANGED
|
@@ -11,7 +11,6 @@ from contextlib import contextmanager
|
|
|
11
11
|
|
|
12
12
|
import numpy as np
|
|
13
13
|
import torch
|
|
14
|
-
from mne.utils.check import check_version
|
|
15
14
|
from skorch.callbacks.scoring import EpochScoring
|
|
16
15
|
from skorch.dataset import unpack_data
|
|
17
16
|
from skorch.utils import to_numpy
|
|
@@ -370,13 +369,8 @@ class PostEpochTrainScoring(EpochScoring):
|
|
|
370
369
|
y_preds = []
|
|
371
370
|
y_test = []
|
|
372
371
|
for batch in iterator:
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
if not check_version("skorch", min_version="0.10.1"):
|
|
376
|
-
yp = net.evaluation_step(batch_X, training=False)
|
|
377
|
-
# X, y unpacking has been pushed downstream in skorch 0.10
|
|
378
|
-
else:
|
|
379
|
-
yp = net.evaluation_step(batch, training=False)
|
|
372
|
+
_, batch_y = unpack_data(batch)
|
|
373
|
+
yp = net.evaluation_step(batch, training=False)
|
|
380
374
|
yp = yp.to(device="cpu")
|
|
381
375
|
y_test.append(self.target_extractor(batch_y))
|
|
382
376
|
y_preds.append(yp)
|
braindecode/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "1.2.0.
|
|
1
|
+
__version__ = "1.2.0.dev176358851"
|
|
@@ -6,8 +6,13 @@ import numpy as np
|
|
|
6
6
|
import torch
|
|
7
7
|
from skorch.utils import to_numpy, to_tensor
|
|
8
8
|
|
|
9
|
+
from braindecode.util import set_random_seeds
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
|
|
12
|
+
def compute_amplitude_gradients(model, dataset, batch_size, seed=20240205):
|
|
13
|
+
"""Compute amplitude gradients after seeding for reproducibility."""
|
|
14
|
+
cuda = next(model.parameters()).is_cuda
|
|
15
|
+
set_random_seeds(seed=seed, cuda=cuda)
|
|
11
16
|
loader = torch.utils.data.DataLoader(
|
|
12
17
|
dataset, batch_size=batch_size, drop_last=False, shuffle=False
|
|
13
18
|
)
|
{braindecode-1.2.0.dev169062562.dist-info → braindecode-1.2.0.dev176358851.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: braindecode
|
|
3
|
-
Version: 1.2.0.
|
|
3
|
+
Version: 1.2.0.dev176358851
|
|
4
4
|
Summary: Deep learning software to decode EEG, ECG or MEG signals
|
|
5
5
|
Author-email: Robin Tibor Schirrmeister <robintibor@gmail.com>
|
|
6
6
|
Maintainer-email: Alexandre Gramfort <agramfort@meta.com>, Bruno Aristimunha Pinto <b.aristimunha@gmail.com>, Robin Tibor Schirrmeister <robintibor@gmail.com>
|
{braindecode-1.2.0.dev169062562.dist-info → braindecode-1.2.0.dev176358851.dist-info}/RECORD
RENAMED
|
@@ -3,7 +3,7 @@ braindecode/classifier.py,sha256=k9vSCtfQbld0YVleDi5rrrmk6k_k5JYEPPBYcNxYjZ8,980
|
|
|
3
3
|
braindecode/eegneuralnet.py,sha256=dz8k_-2jV7WqkaX4bQG-dmr-vRT7ZtOwJqomXyC9PTw,15287
|
|
4
4
|
braindecode/regressor.py,sha256=VLfrpiXklwI4onkwue3QmzlBWcvspu0tlrLo9RT1Oiw,9375
|
|
5
5
|
braindecode/util.py,sha256=J-tBcDJNlMTIFW2mfOy6Ko0nsgdP4obRoEVDeg2rFH0,12686
|
|
6
|
-
braindecode/version.py,sha256=
|
|
6
|
+
braindecode/version.py,sha256=pqOP2XIkF23sSxHn98gks8lm_NZ40LR5V6vz_cuxJQo,35
|
|
7
7
|
braindecode/augmentation/__init__.py,sha256=LG7ONqCufYAF9NZt8POIp10lYXb8iSueYkF-CWGK2Ls,1001
|
|
8
8
|
braindecode/augmentation/base.py,sha256=gg7wYsVfa9jfqBddtE03B5ZrPHFFmPl2sa3LOrRnGfo,7325
|
|
9
9
|
braindecode/augmentation/functional.py,sha256=ygkMNEFHaUdRQfk7meMML19FnM406Uf34h-ztKXdJwM,37978
|
|
@@ -35,12 +35,12 @@ braindecode/models/contrawr.py,sha256=eeR_ik4gNZ3rJLM6Mw9gJ2gTMkZ8CU8C4rN_GQMQTA
|
|
|
35
35
|
braindecode/models/ctnet.py,sha256=-J9QtUM8kcntz_xinfuBBvwDMECHiMPMcr2MS4GDPEY,17308
|
|
36
36
|
braindecode/models/deep4.py,sha256=YJQUw-0EuFUi4qjm8caJGB8wRM_aeJa5X_d8jrGaQAI,14588
|
|
37
37
|
braindecode/models/deepsleepnet.py,sha256=RrciuVJtZ-fhiUl-yLPfK2FP-G29V5Wor6pPlrMHQWQ,9218
|
|
38
|
-
braindecode/models/eegconformer.py,sha256=
|
|
38
|
+
braindecode/models/eegconformer.py,sha256=OSORbNYwMA0hvUMjuyB8wI8qBKVSiraioLHTHmt8sdQ,17376
|
|
39
39
|
braindecode/models/eeginception_erp.py,sha256=mwh3rGSHAJVvnbOlYTuWWkKxlmFAdAXBNCrq4IPgOS4,11408
|
|
40
40
|
braindecode/models/eeginception_mi.py,sha256=aKJRFuYrpbcRbmmT2xVghKbK8pnl7fzu5hrV0ybRKso,12424
|
|
41
41
|
braindecode/models/eegitnet.py,sha256=feXFmPCd-Ejxt7jgWPen1Ag0-oSclDVQai0Atwu9d_A,9827
|
|
42
42
|
braindecode/models/eegminer.py,sha256=ouKZah9Q7_sxT7DJJMcPObwVxNQE87sEljJg6QwiQNw,9847
|
|
43
|
-
braindecode/models/eegnet.py,sha256=
|
|
43
|
+
braindecode/models/eegnet.py,sha256=YeBCmU6Al9FDS4MZQTOLd0MCUfPbM6tmVlGWpb59Qzg,19256
|
|
44
44
|
braindecode/models/eegnex.py,sha256=KNJIh8pFNhY087Bey2OPzDD4Uqw9pS6UkwMjnOngBzg,8497
|
|
45
45
|
braindecode/models/eegresnet.py,sha256=cqWOSGqfJN_dNYUU9l8nYd_S3T1N-UX5-encKQzfBlg,12057
|
|
46
46
|
braindecode/models/eegsimpleconv.py,sha256=sHpK-7ZGOCMuXsdkSVuarFTd1T0jMJUP_xwXP3gxQwc,7268
|
|
@@ -69,10 +69,10 @@ braindecode/models/usleep.py,sha256=dFh3KiZITu13gMxcbPGoK4hq2ySDWzVSCQXkj1006w0,
|
|
|
69
69
|
braindecode/models/util.py,sha256=VrhwG1YBGwKohCej6TmhrNAIoleQHRu3YdiBPuHFY_E,5302
|
|
70
70
|
braindecode/modules/__init__.py,sha256=PD2LpeSHWW_MgEef7-G8ief5gheGObzsIoacchxWuyA,1756
|
|
71
71
|
braindecode/modules/activation.py,sha256=lTO2IjZWBDeXZ4ZVDgLmTDmxHdqyAny3Fsy07HY9tmQ,1466
|
|
72
|
-
braindecode/modules/attention.py,sha256=
|
|
72
|
+
braindecode/modules/attention.py,sha256=ISE11jXAvMqKpawZilg8i7lDX5mkuvpEplrh_CtGEkk,24102
|
|
73
73
|
braindecode/modules/blocks.py,sha256=QE34HBg7kmEj0z-8dQZ1jJErLRPcniGIorMTeIArpv4,3621
|
|
74
|
-
braindecode/modules/convolution.py,sha256=
|
|
75
|
-
braindecode/modules/filter.py,sha256=
|
|
74
|
+
braindecode/modules/convolution.py,sha256=gZMMOa-2gy1nfduA_j2ezgdIdq5Bi2PtonNomWA4D8k,8481
|
|
75
|
+
braindecode/modules/filter.py,sha256=iCz0HiGKrBS09m3aGiNnZEt8jpYOOrmn6SpPCUcuHfU,25291
|
|
76
76
|
braindecode/modules/layers.py,sha256=w_tAGcm8BDFiyMdAYM4DNLx46zIUted8B6my8_jtpps,3724
|
|
77
77
|
braindecode/modules/linear.py,sha256=pNhSUU0u-IGEUCjAfEDq_TJWnIJMWuOk7Y5L-7I8Meg,1702
|
|
78
78
|
braindecode/modules/parametrization.py,sha256=sTvV21-sdpqpiY2PzwDebi7SeEvkFw8yDgA6OqJDo34,1310
|
|
@@ -89,13 +89,13 @@ braindecode/samplers/ssl.py,sha256=C-FKopnbncN_-spQPCrgljY5Qds4fgTLr2TG3s_-QqU,9
|
|
|
89
89
|
braindecode/training/__init__.py,sha256=sxtfI6MgxX3aP03EFc0wJYA37uULoL9SQyUao1Oxyn0,523
|
|
90
90
|
braindecode/training/callbacks.py,sha256=LqXqzJd6s3w0pvAKy9TEVTxWwVRyWNEu2uyWVsvb9RQ,839
|
|
91
91
|
braindecode/training/losses.py,sha256=EyVVZE_028G6WwrAtzLbrRfDLgsoKwLLhqIkOYBXNL4,3551
|
|
92
|
-
braindecode/training/scoring.py,sha256=
|
|
92
|
+
braindecode/training/scoring.py,sha256=WRkwqbitA3m_dzRnGp2ZIZPge5Nhx9gAEQhIHzeH4eU,18716
|
|
93
93
|
braindecode/visualization/__init__.py,sha256=4EER_xHqZIDzEvmgUEm7K1bgNKpyZAIClR9ZCkMuY4M,240
|
|
94
94
|
braindecode/visualization/confusion_matrices.py,sha256=qIWMLEHow5CJ7PhGggD8mnD55Le6xhma9HSzt4R33fc,9509
|
|
95
|
-
braindecode/visualization/gradients.py,sha256=
|
|
96
|
-
braindecode-1.2.0.
|
|
97
|
-
braindecode-1.2.0.
|
|
98
|
-
braindecode-1.2.0.
|
|
99
|
-
braindecode-1.2.0.
|
|
100
|
-
braindecode-1.2.0.
|
|
101
|
-
braindecode-1.2.0.
|
|
95
|
+
braindecode/visualization/gradients.py,sha256=KZo-GA0uwiwty2_94j2IjmCR2SKcfPb1Bi3sQq7vpTk,2170
|
|
96
|
+
braindecode-1.2.0.dev176358851.dist-info/licenses/LICENSE.txt,sha256=7rg7k6hyj8m9whQ7dpKbqnCssoOEx_Mbtqb4uSOjljE,1525
|
|
97
|
+
braindecode-1.2.0.dev176358851.dist-info/licenses/NOTICE.txt,sha256=sOxuTbalPxTM8H6VqtvGbXCt_BoOF7JevEYG_knqbm4,620
|
|
98
|
+
braindecode-1.2.0.dev176358851.dist-info/METADATA,sha256=23uR3nYKaKV2G4EtrutqVU6r40qFe4_Oh9DuXDX5fFI,6883
|
|
99
|
+
braindecode-1.2.0.dev176358851.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
100
|
+
braindecode-1.2.0.dev176358851.dist-info/top_level.txt,sha256=pHsWQmSy0uhIez62-HA9j0iaXKvSbUL39ifFRkFnChA,12
|
|
101
|
+
braindecode-1.2.0.dev176358851.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{braindecode-1.2.0.dev169062562.dist-info → braindecode-1.2.0.dev176358851.dist-info}/top_level.txt
RENAMED
|
File without changes
|