braindecode 1.2.0.dev169062562__py3-none-any.whl → 1.2.0.dev184328194__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.

@@ -157,7 +157,8 @@ class FCA(nn.Module):
157
157
  ):
158
158
  super(FCA, self).__init__()
159
159
  mapper_y = [freq_idx]
160
- assert in_channels % len(mapper_y) == 0
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
- assert kernel_size % 2 == 1, "kernel size must be odd for same padding"
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
- assert kernel_size % 2 == 1, "kernel size must be odd for same padding"
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
- assert time_bias is not None
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
- assert spat_bias is not None
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
- assert "padding" not in kwargs, (
194
- "The padding parameter is controlled internally by "
195
- f"{type(self).__name__} class. You should not try to override this"
196
- " parameter."
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,
@@ -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
- assert out_channels % in_channels == 0, (
456
- "out_channels has to be multiple of in_channels"
457
- )
458
- assert len(f_mean) * in_channels == out_channels
459
- assert len(bandwidth) * in_channels == out_channels
460
- assert len(shape) * in_channels == out_channels
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(
@@ -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
- batch_X, batch_y = unpack_data(batch)
374
- # TODO: remove after skorch 0.10 release
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.dev169062562"
1
+ __version__ = "1.2.0.dev184328194"
@@ -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
- def compute_amplitude_gradients(model, dataset, batch_size):
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
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: braindecode
3
- Version: 1.2.0.dev169062562
3
+ Version: 1.2.0.dev184328194
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>
@@ -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=peEUr8wSaU7Geu5W6LeP3IamWD3aza4xEKMC4rdjQl4,35
6
+ braindecode/version.py,sha256=Adl2q0noMgIED1dlngWz_nvDbzU6GpgOYSGTS9Fs6io,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
@@ -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=fsjruzqMdtPbcS6jbU5ux8xtHl0BVrKt4agyf2yNe_E,23966
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=VAqJXj1Xfb7qlnjRAhH_fJT8qPcaAqy5FHu_sNEbkWw,8291
75
- braindecode/modules/filter.py,sha256=tj3zFQf40kt605yKE3bGpmnxtf91FTY7cWqxwAIIGPc,25050
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=tG7uCojIG3KIQZq3AymrdwlIJLlzbgsS0nBLUXQ-A8s,19062
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=qAtXmuXkCDsWs8RMxvE6T9dz3uv_BhwTqhzkFFsEUDI,1948
96
- braindecode-1.2.0.dev169062562.dist-info/licenses/LICENSE.txt,sha256=7rg7k6hyj8m9whQ7dpKbqnCssoOEx_Mbtqb4uSOjljE,1525
97
- braindecode-1.2.0.dev169062562.dist-info/licenses/NOTICE.txt,sha256=sOxuTbalPxTM8H6VqtvGbXCt_BoOF7JevEYG_knqbm4,620
98
- braindecode-1.2.0.dev169062562.dist-info/METADATA,sha256=-76DvxesVFpEyLE_1OeR6BFkmbyz5Hij3w-epsTsM3w,6883
99
- braindecode-1.2.0.dev169062562.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
100
- braindecode-1.2.0.dev169062562.dist-info/top_level.txt,sha256=pHsWQmSy0uhIez62-HA9j0iaXKvSbUL39ifFRkFnChA,12
101
- braindecode-1.2.0.dev169062562.dist-info/RECORD,,
95
+ braindecode/visualization/gradients.py,sha256=KZo-GA0uwiwty2_94j2IjmCR2SKcfPb1Bi3sQq7vpTk,2170
96
+ braindecode-1.2.0.dev184328194.dist-info/licenses/LICENSE.txt,sha256=7rg7k6hyj8m9whQ7dpKbqnCssoOEx_Mbtqb4uSOjljE,1525
97
+ braindecode-1.2.0.dev184328194.dist-info/licenses/NOTICE.txt,sha256=sOxuTbalPxTM8H6VqtvGbXCt_BoOF7JevEYG_knqbm4,620
98
+ braindecode-1.2.0.dev184328194.dist-info/METADATA,sha256=PgPq5CmBC6TDByTBtGn3Gtf6yaAJW96CZ_3J5BgGhDc,6883
99
+ braindecode-1.2.0.dev184328194.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
100
+ braindecode-1.2.0.dev184328194.dist-info/top_level.txt,sha256=pHsWQmSy0uhIez62-HA9j0iaXKvSbUL39ifFRkFnChA,12
101
+ braindecode-1.2.0.dev184328194.dist-info/RECORD,,