braindecode 2.1.0.dev180967944__tar.gz → 2.1.0.dev180970067__tar.gz

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.
Files changed (227) hide show
  1. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/NOTICE.txt +14 -0
  2. {braindecode-2.1.0.dev180967944/braindecode.egg-info → braindecode-2.1.0.dev180970067}/PKG-INFO +1 -1
  3. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/functional/attention.py +12 -54
  4. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/functional/channel_mask.py +18 -10
  5. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/__init__.py +3 -0
  6. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/biot.py +31 -19
  7. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/brainmodule.py +1 -13
  8. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/cbramod.py +9 -5
  9. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/codebrain.py +13 -16
  10. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/corteg.py +2 -20
  11. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/csbrain.py +12 -9
  12. braindecode-2.1.0.dev180970067/braindecode/models/fnirs4d.py +419 -0
  13. braindecode-2.1.0.dev180970067/braindecode/models/fnirs_t.py +477 -0
  14. braindecode-2.1.0.dev180970067/braindecode/models/fnirsnet.py +192 -0
  15. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/labram.py +4 -18
  16. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/luna.py +5 -1
  17. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/meggpt.py +22 -4
  18. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/reve.py +1 -4
  19. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/signal_jepa.py +3 -4
  20. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/summary.csv +4 -0
  21. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/util.py +148 -0
  22. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/zuna.py +10 -18
  23. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/modules/attention.py +9 -9
  24. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/modules/layers.py +2 -8
  25. braindecode-2.1.0.dev180970067/braindecode/version.py +1 -0
  26. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067/braindecode.egg-info}/PKG-INFO +1 -1
  27. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode.egg-info/SOURCES.txt +4 -0
  28. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/api.rst +4 -0
  29. braindecode-2.1.0.dev180970067/docs/install/gaudi.rst +99 -0
  30. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/install/install.rst +3 -0
  31. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/models/models_table.rst +2 -2
  32. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/whats_new.rst +92 -1
  33. braindecode-2.1.0.dev180967944/braindecode/version.py +0 -1
  34. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/LICENSE.txt +0 -0
  35. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/MANIFEST.in +0 -0
  36. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/README.rst +0 -0
  37. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/__init__.py +0 -0
  38. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/augmentation/__init__.py +0 -0
  39. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/augmentation/base.py +0 -0
  40. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/augmentation/functional.py +0 -0
  41. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/augmentation/transforms.py +0 -0
  42. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/classifier.py +0 -0
  43. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/__init__.py +0 -0
  44. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/_notebook_viewer.py +0 -0
  45. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/base.py +0 -0
  46. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/bbci.py +0 -0
  47. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/bcicomp.py +0 -0
  48. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/bids/__init__.py +0 -0
  49. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/bids/datasets.py +0 -0
  50. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/bids/hub.py +0 -0
  51. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/bids/hub_format.py +0 -0
  52. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/bids/hub_io.py +0 -0
  53. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/bids/hub_validation.py +0 -0
  54. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/bids/iterable.py +0 -0
  55. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/chb_mit.py +0 -0
  56. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/collate.py +0 -0
  57. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/mne.py +0 -0
  58. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/moabb.py +0 -0
  59. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/nmt.py +0 -0
  60. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/registry.py +0 -0
  61. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/siena.py +0 -0
  62. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/sleep_physio_challe_18.py +0 -0
  63. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/sleep_physionet.py +0 -0
  64. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/tuh.py +0 -0
  65. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/utils.py +0 -0
  66. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datasets/xy.py +0 -0
  67. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datautil/__init__.py +0 -0
  68. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datautil/channel_utils.py +0 -0
  69. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datautil/hub_formats.py +0 -0
  70. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datautil/serialization.py +0 -0
  71. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/datautil/util.py +0 -0
  72. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/eegneuralnet.py +0 -0
  73. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/functional/__init__.py +0 -0
  74. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/functional/_lfilter.py +0 -0
  75. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/functional/_real_dft.py +0 -0
  76. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/functional/functions.py +0 -0
  77. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/functional/initialization.py +0 -0
  78. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/functional/patches.py +0 -0
  79. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/atcnet.py +0 -0
  80. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/attentionbasenet.py +0 -0
  81. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/attn_sleep.py +0 -0
  82. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/axon.py +0 -0
  83. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/barista.py +0 -0
  84. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/base.py +0 -0
  85. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/bbl.py +0 -0
  86. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/bendr.py +0 -0
  87. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/brainbert.py +0 -0
  88. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/brainomni.py +0 -0
  89. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/brant.py +0 -0
  90. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/config.py +0 -0
  91. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/contrawr.py +0 -0
  92. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/ctnet.py +0 -0
  93. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/dance.py +0 -0
  94. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/deep4.py +0 -0
  95. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/deepsleepnet.py +0 -0
  96. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/dgcnn.py +0 -0
  97. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/diver1.py +0 -0
  98. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/duin.py +0 -0
  99. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/eeg_clip.py +0 -0
  100. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/eegconformer.py +0 -0
  101. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/eegdino.py +0 -0
  102. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/eeginception_erp.py +0 -0
  103. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/eeginception_mi.py +0 -0
  104. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/eegitnet.py +0 -0
  105. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/eegminer.py +0 -0
  106. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/eegnet.py +0 -0
  107. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/eegnex.py +0 -0
  108. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/eegpt.py +0 -0
  109. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/eegsimpleconv.py +0 -0
  110. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/eegsym.py +0 -0
  111. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/eegtcnet.py +0 -0
  112. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/emg2qwerty.py +0 -0
  113. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/epint.py +0 -0
  114. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/fbcnet.py +0 -0
  115. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/fblightconvnet.py +0 -0
  116. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/fbmsnet.py +0 -0
  117. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/gcnsnet.py +0 -0
  118. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/guetschel2026.py +0 -0
  119. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/hybrid.py +0 -0
  120. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/ifnet.py +0 -0
  121. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/mapa.py +0 -0
  122. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/medformer.py +0 -0
  123. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/megxl.py +0 -0
  124. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/meta_neuromotor.py +0 -0
  125. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/mirepnet.py +0 -0
  126. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/model.html.jinja +0 -0
  127. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/mscformer.py +0 -0
  128. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/msvtnet.py +0 -0
  129. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/mvpformer.py +0 -0
  130. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/neuropose.py +0 -0
  131. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/neurorvq.py +0 -0
  132. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/neurorvq_tokenizer.py +0 -0
  133. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/nice.py +0 -0
  134. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/patchedtransformer.py +0 -0
  135. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/popt.py +0 -0
  136. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/sccnet.py +0 -0
  137. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/seizure_transformer.py +0 -0
  138. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/sensingdynamics.py +0 -0
  139. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/shallow_fbcsp.py +0 -0
  140. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/sinc_shallow.py +0 -0
  141. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/sleep_stager_blanco_2020.py +0 -0
  142. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/sleep_stager_chambon_2018.py +0 -0
  143. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/sleepfm.py +0 -0
  144. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/sparcnet.py +0 -0
  145. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/sstdpn.py +0 -0
  146. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/steegformer.py +0 -0
  147. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/syncnet.py +0 -0
  148. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/tccnet.py +0 -0
  149. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/tcformer.py +0 -0
  150. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/tcn.py +0 -0
  151. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/tfm_tokenizer.py +0 -0
  152. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/tidnet.py +0 -0
  153. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/tmsanet.py +0 -0
  154. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/tsinception.py +0 -0
  155. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/usleep.py +0 -0
  156. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/models/vemg2pose.py +0 -0
  157. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/modules/__init__.py +0 -0
  158. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/modules/activation.py +0 -0
  159. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/modules/blocks.py +0 -0
  160. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/modules/channels.py +0 -0
  161. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/modules/convolution.py +0 -0
  162. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/modules/dance_modules.py +0 -0
  163. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/modules/filter.py +0 -0
  164. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/modules/linear.py +0 -0
  165. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/modules/linear_attention.py +0 -0
  166. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/modules/parametrization.py +0 -0
  167. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/modules/quantization.py +0 -0
  168. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/modules/seanet.py +0 -0
  169. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/modules/stats.py +0 -0
  170. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/modules/util.py +0 -0
  171. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/modules/wrapper.py +0 -0
  172. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/preprocessing/__init__.py +0 -0
  173. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/preprocessing/eegprep_preprocess.py +0 -0
  174. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/preprocessing/mne_preprocess.py +0 -0
  175. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/preprocessing/preprocess.py +0 -0
  176. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/preprocessing/util.py +0 -0
  177. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/preprocessing/windowers.py +0 -0
  178. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/regressor.py +0 -0
  179. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/samplers/__init__.py +0 -0
  180. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/samplers/base.py +0 -0
  181. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/samplers/ssl.py +0 -0
  182. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/training/__init__.py +0 -0
  183. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/training/_trial_aggregation.py +0 -0
  184. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/training/callbacks.py +0 -0
  185. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/training/losses.py +0 -0
  186. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/training/scoring.py +0 -0
  187. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/util.py +0 -0
  188. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/visualization/__init__.py +0 -0
  189. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/visualization/activations.py +0 -0
  190. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/visualization/attribution.py +0 -0
  191. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/visualization/confusion_matrices.py +0 -0
  192. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/visualization/frequency.py +0 -0
  193. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/visualization/metrics.py +0 -0
  194. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/visualization/sanity.py +0 -0
  195. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode/visualization/topology.py +0 -0
  196. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode.egg-info/dependency_links.txt +0 -0
  197. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode.egg-info/requires.txt +0 -0
  198. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/braindecode.egg-info/top_level.txt +0 -0
  199. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/Makefile +0 -0
  200. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/_templates/autosummary/class.rst +0 -0
  201. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/_templates/autosummary/class_in_subdir.rst +0 -0
  202. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/_templates/autosummary/function.rst +0 -0
  203. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/_templates/autosummary/function_in_subdir.rst +0 -0
  204. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/agent_docs.rst +0 -0
  205. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/cite.rst +0 -0
  206. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/conf.py +0 -0
  207. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/help.rst +0 -0
  208. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/index.rst +0 -0
  209. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/install/install_pip.rst +0 -0
  210. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/install/install_source.rst +0 -0
  211. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/models/categorization/attention.rst +0 -0
  212. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/models/categorization/channel.rst +0 -0
  213. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/models/categorization/convolution.rst +0 -0
  214. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/models/categorization/filterbank.rst +0 -0
  215. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/models/categorization/gnn.rst +0 -0
  216. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/models/categorization/interpretable.rst +0 -0
  217. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/models/categorization/lbm.rst +0 -0
  218. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/models/categorization/recurrent.rst +0 -0
  219. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/models/categorization/spd.rst +0 -0
  220. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/models/models.rst +0 -0
  221. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/models/models_categorization.rst +0 -0
  222. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/models/models_visualization.rst +0 -0
  223. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/sg_execution_times.rst +0 -0
  224. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/user_guide/channel_strategies.rst +0 -0
  225. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/docs/user_guide/cropped_inference.rst +0 -0
  226. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/pyproject.toml +0 -0
  227. {braindecode-2.1.0.dev180967944 → braindecode-2.1.0.dev180970067}/setup.cfg +0 -0
@@ -62,6 +62,8 @@ The following components are licensed under the MIT License:
62
62
  - `braindecode/models/meggpt.py`
63
63
  - `braindecode/models/megxl.py`
64
64
  - `braindecode/models/nice.py`
65
+ - `braindecode/models/fnirs_t.py`
66
+ - `docs/_static/model/fnirst.png` (wzhlearning/fNIRS-Transformer `fig/model.png`)
65
67
  - `braindecode/models/tccnet.py`
66
68
  - `docs/_static/model/tccnet.png`
67
69
 
@@ -88,6 +90,17 @@ The following components are licensed under the Apache License 2.0:
88
90
  - `braindecode/models/brant.py`
89
91
  - `braindecode/models/diver1.py`
90
92
  - `braindecode/models/mscformer.py`
93
+ - `braindecode/models/fnirsnet.py`
94
+ - `braindecode/models/fnirs4d.py`
95
+ - `docs/_static/model/fnirs4d.png` (wzhlearning/fNIRS4D `fig/fig2.png`, resized)
96
+
97
+ ### CC BY 4.0 Licensed Files
98
+
99
+ The following figures are reproduced from open-access papers under the
100
+ Creative Commons Attribution 4.0 International License (each docstring
101
+ cites the paper):
102
+
103
+ - `docs/_static/model/fnirsnet.png` (Wang et al., IEEE TNSRE 2023, Fig. 2, cropped)
91
104
 
92
105
  ### USC Academic License Files
93
106
 
@@ -103,6 +116,7 @@ The following components are licensed under the Apache License 2.0:
103
116
  - [CC BY-NC-SA 4.0 License](https://creativecommons.org/licenses/by-nc-sa/4.0/)
104
117
  - [MIT License](https://opensource.org/licenses/MIT)
105
118
  - [Apache-2.0 License](https://www.apache.org/licenses/LICENSE-2.0)
119
+ - [CC BY 4.0 License](https://creativecommons.org/licenses/by/4.0/)
106
120
  - [USC Academic License](https://github.com/ShanechiLab/BaRISTA/blob/master/LICENSE.md)
107
121
 
108
122
  ## Note
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: braindecode
3
- Version: 2.1.0.dev180967944
3
+ Version: 2.1.0.dev180970067
4
4
  Summary: Deep learning software to decode EEG, ECG or MEG signals
5
5
  Author-email: Robin Tibor Schirrmeister <robintibor@gmail.com>, Bruno Aristimunha Pinto <b.aristimunha@gmail.com>, Alexandre Gramfort <agramfort@meta.com>
6
6
  Maintainer-email: Alexandre Gramfort <agramfort@meta.com>, Bruno Aristimunha Pinto <b.aristimunha@gmail.com>, Robin Tibor Schirrmeister <robintibor@gmail.com>
@@ -12,35 +12,6 @@ import torch.nn.functional as F
12
12
  from torch import Tensor
13
13
 
14
14
 
15
- @torch.jit.unused
16
- def _hpu_eager_fused_sdpa(
17
- query: Tensor,
18
- key: Tensor,
19
- value: Tensor,
20
- scale: Optional[float] = None,
21
- fused_in_lazy: bool = False,
22
- ) -> Optional[Tensor]:
23
- # Lazy mode: None, the graph compiler already fuses torch's SDPA there
24
- # (unless the caller measured the fused kernel faster for its shapes).
25
- from habana_frameworks.torch.utils.internal import is_lazy
26
-
27
- if is_lazy() and not fused_in_lazy:
28
- return None
29
- from habana_frameworks.torch.hpex.kernels import FusedSDPA
30
-
31
- # Strided q/k/v views (heads split off a projection) give wrong outputs and
32
- # gradients at some shapes; contiguous copies give the right result.
33
- query, key, value = query.contiguous(), key.contiguous(), value.contiguous()
34
- return FusedSDPA.apply(query, key, value, None, 0.0, False, scale, "None", False)
35
-
36
-
37
- @torch.jit.unused
38
- def _hpu_lazy() -> bool:
39
- from habana_frameworks.torch.utils.internal import is_lazy
40
-
41
- return is_lazy()
42
-
43
-
44
15
  def _sdpa_math_dropout(
45
16
  query: Tensor,
46
17
  key: Tensor,
@@ -69,7 +40,7 @@ def scaled_dot_product_attention(
69
40
  fused_in_lazy: bool = False,
70
41
  exact: bool = False,
71
42
  ) -> Tensor:
72
- """``F.scaled_dot_product_attention``; Gaudi's fused kernel on HPU.
43
+ """``F.scaled_dot_product_attention``, or the textbook op order (``exact``).
73
44
 
74
45
  Parameters
75
46
  ----------
@@ -83,7 +54,9 @@ def scaled_dot_product_attention(
83
54
  scale : float, optional
84
55
  Score scale; ``None`` is ``1 / sqrt(head_dim)``.
85
56
  fused_in_lazy : bool, default=False
86
- Use Gaudi's fused kernel in HPU lazy mode too.
57
+ No effect; kept so that existing calls still work. On Intel Gaudi,
58
+ Habana's attention setting decides whether this call runs on the
59
+ bridge's fused kernel (:ref:`install_gaudi`).
87
60
  exact : bool, default=False
88
61
  Run the textbook op order instead of torch's kernels:
89
62
  ``softmax((q @ k^T) / sqrt(d)) @ v``, or ``softmax((q @ k^T) * scale) @ v``
@@ -97,12 +70,12 @@ def scaled_dot_product_attention(
97
70
  torch.Tensor
98
71
  Shape ``(..., seq, head_dim)``.
99
72
 
100
- In HPU eager mode, torch's SDPA runs op by op (the full
101
- ``(batch, heads, seq, seq)`` scores in device memory), 2-3.5x slower than
102
- the bridge's fused kernel on long sequences. The fused kernel is used
103
- without a mask or dropout (its dropout would draw other masks). In lazy
104
- mode only with ``fused_in_lazy=True``: the graph compiler fuses torch's
105
- SDPA too, faster on long sequences, slower on short ones.
73
+ Notes
74
+ -----
75
+ On Intel Gaudi, torch's SDPA runs op by op unless Habana's attention
76
+ setting is on; then the bridge's fused kernel runs it, with or without a
77
+ mask (:ref:`install_gaudi`), dropout included. On CPU, dropout on float32
78
+ or float64 inputs without a mask keeps torch's math path.
106
79
  """
107
80
  if exact:
108
81
  scores = torch.matmul(query, key.transpose(-2, -1))
@@ -119,29 +92,14 @@ def scaled_dot_product_attention(
119
92
  if dropout_p > 0.0:
120
93
  weights = F.dropout(weights, dropout_p, True)
121
94
  return torch.matmul(weights, value)
122
- if (
123
- not torch.jit.is_scripting()
124
- and query.device.type == "hpu"
125
- and attn_mask is None
126
- and dropout_p == 0.0
127
- and (query.dtype == torch.float32 or query.dtype == torch.bfloat16)
128
- ):
129
- out = _hpu_eager_fused_sdpa(
130
- query, key, value, scale=scale, fused_in_lazy=fused_in_lazy
131
- )
132
- if out is not None:
133
- return out
134
95
  if (
135
96
  not torch.jit.is_scripting()
136
97
  and dropout_p > 0.0
137
98
  and attn_mask is None
138
99
  and (query.dtype == torch.float32 or query.dtype == torch.float64)
139
- and (
140
- query.device.type == "cpu"
141
- or (query.device.type == "hpu" and not _hpu_lazy())
142
- )
100
+ and query.device.type == "cpu"
143
101
  ):
144
- # CPU and HPU eager run SDPA with dropout through the math path.
102
+ # The CPU runs SDPA with dropout through the math path.
145
103
  return _sdpa_math_dropout(query, key, value, dropout_p, scale)
146
104
  if scale is None: # torch 2.0's signature has no ``scale``
147
105
  return F.scaled_dot_product_attention(
@@ -192,20 +192,28 @@ def masked_group_norm(
192
192
  # Remove NaNs before subtraction, squaring and affine multiplication;
193
193
  # masking only the resulting statistics does not protect backward.
194
194
  x = x.masked_fill(padding, 0.0)
195
- # (batch, ..., group, channel): the mask covers the leading axes.
196
- grouped = x.movedim(1, -1).unflatten(-1, [num_groups, -1])
195
+ # (batch, group, channel, ...): a view of the channel axis, no permute.
197
196
  # At least float32 statistics, as group_norm accumulates reduced precision.
198
- grouped = grouped.to(torch.promote_types(x.dtype, torch.float32))
197
+ grouped = x.unflatten(1, [num_groups, -1]).to(
198
+ torch.promote_types(x.dtype, torch.float32)
199
+ )
199
200
  dims: List[int] = []
200
- for dim in range(1, grouped.dim() - 2):
201
+ for dim in range(2, grouped.dim()):
201
202
  dims.append(dim)
202
- dims.append(grouped.dim() - 1)
203
- stats_shape = [grouped.shape[0]] + [1] * (grouped.dim() - 3) + [num_groups, 1]
204
- mean = masked_mean(grouped, mask, dims).reshape(stats_shape)
205
- centred = grouped - mean
203
+ stats_shape = [x.shape[0]] + [1] * (grouped.dim() - 1)
204
+ # Real entries per sample and group, from the small mask rather than a
205
+ # full-size masked count: channels per group times the axes past the mask.
206
+ per_position = x.shape[1] // num_groups
207
+ for size in x.shape[mask.dim() + 1 :]:
208
+ per_position *= size
209
+ count = (mask.reshape(mask.shape[0], -1).sum(1) * per_position).to(grouped.dtype)
210
+ count = count.reshape(stats_shape)
211
+ # Padded entries are zero, so plain sums are the masked sums.
212
+ mean = grouped.sum(dims, keepdim=True) / count
213
+ centred = (grouped - mean).masked_fill(padding.unsqueeze(1), 0.0)
206
214
  # Biased variance, as group_norm.
207
- var = masked_mean(centred.square(), mask, dims).reshape(stats_shape)
208
- out = (centred * torch.rsqrt(var + eps)).flatten(-2).movedim(-1, 1)
215
+ var = centred.square().sum(dims, keepdim=True) / count
216
+ out = (centred * torch.rsqrt(var + eps)).flatten(1, 2)
209
217
  affine_shape = [1, x.shape[1]] + [1] * (x.dim() - 2)
210
218
  if weight is not None:
211
219
  out = out * weight.reshape(affine_shape)
@@ -54,6 +54,9 @@ if TYPE_CHECKING:
54
54
  from .fbcnet import FBCNet
55
55
  from .fblightconvnet import FBLightConvNet
56
56
  from .fbmsnet import FBMSNet
57
+ from .fnirs4d import FNIRS4D
58
+ from .fnirs_t import FNIRST, FNIRSPreT
59
+ from .fnirsnet import FNIRSNet
57
60
  from .gcnsnet import GCNsNet
58
61
  from .guetschel2026 import Guetschel2026
59
62
  from .hybrid import HybridNet
@@ -257,8 +257,8 @@ class BIOT(EEGModuleMixin, nn.Module):
257
257
  x: Tensor
258
258
  (batch_size, n_channels, n_times)
259
259
  return_features : bool
260
- If True, return a dict with ``"features"`` and ``"cls_token"``
261
- instead of the classification output.
260
+ If True, return a dict with ``"features"``, ``"cls_token"`` and
261
+ ``"tokens"`` instead of the classification output.
262
262
  ch_mask : torch.Tensor, optional
263
263
  ``(batch, n_chans)`` mask of real channels, see
264
264
  :func:`~braindecode.functional.check_ch_mask`. Padded channels are
@@ -269,16 +269,24 @@ class BIOT(EEGModuleMixin, nn.Module):
269
269
  torch.Tensor or tuple or dict
270
270
  Default: ``torch.Tensor`` of shape ``(batch_size, n_outputs)``.
271
271
  If ``return_features=True``: ``dict`` with ``"features"``
272
- ``(batch_size, emb_size)`` and ``"cls_token"`` (``None``).
272
+ ``(batch_size, emb_size)``, the mean of the tokens, ``"cls_token"``
273
+ (``None``) and ``"tokens"`` ``(batch_size, n_channels, n_patches,
274
+ emb_size)``, the transformer output, zero for padded channels.
273
275
  If legacy ``return_feature=True`` (init param):
274
276
  ``(out, emb)`` tuple (ignored when ``return_features=True``).
275
277
  """
276
- emb = self.encoder(x, ch_mask=check_ch_mask(ch_mask, x))
278
+ ch_mask = check_ch_mask(ch_mask, x)
279
+ tokens, token_mask = self.encoder(x, ch_mask=ch_mask)
280
+ emb = masked_mean(tokens, token_mask, [1])
277
281
 
278
282
  if return_features:
283
+ tokens = tokens.unflatten(1, (x.shape[1], -1))
284
+ if ch_mask is not None:
285
+ tokens = tokens.masked_fill(~ch_mask[:, :, None, None], 0.0)
279
286
  out: Dict[str, Optional[torch.Tensor]] = {
280
287
  "features": emb,
281
288
  "cls_token": None,
289
+ "tokens": tokens,
282
290
  }
283
291
  return out
284
292
 
@@ -483,8 +491,7 @@ class _BIOTEncoder(nn.Module):
483
491
  and then embedded using a patch embedding. The channel token
484
492
  is added to the patch embedding, and then positional encoding
485
493
  is applied. The resulting embeddings are concatenated and
486
- passed through a transformer layer. The mean of the resulting
487
- embeddings is returned.
494
+ passed through a transformer layer, whose tokens are returned.
488
495
 
489
496
  For each channel in channels, the channels are transformed into a
490
497
  spectrogram with STFT; The spectrogram representation is permuted
@@ -495,7 +502,7 @@ class _BIOTEncoder(nn.Module):
495
502
  the patch embedding, and then positional encoding is applied.
496
503
 
497
504
  The resulting embeddings are concatenated and passed through a
498
- transformer layer. The mean of the resulting embeddings is returned.
505
+ transformer layer.
499
506
 
500
507
  Parameters
501
508
  ----------
@@ -512,8 +519,12 @@ class _BIOTEncoder(nn.Module):
512
519
 
513
520
  Returns
514
521
  -------
515
- emb: Tensor
516
- (batch_size, emb_size)
522
+ tokens: Tensor
523
+ (batch_size, n_channels * n_patches, emb_size), channel-major
524
+ (with ``perturb``, channels keep different numbers of patches).
525
+ token_mask: Tensor or None
526
+ (batch_size, n_channels * n_patches) mask of the tokens of real
527
+ channels; None without ``ch_mask``.
517
528
  """
518
529
  batch_size, n_chans, n_times = x.shape
519
530
  if ch_mask is not None:
@@ -523,6 +534,12 @@ class _BIOTEncoder(nn.Module):
523
534
  # channel's (batch, freq, ts) block is contiguous
524
535
  spec = self.stft(x.transpose(0, 1).reshape(n_chans * batch_size, 1, n_times))
525
536
  spec = spec.unflatten(0, [n_chans, batch_size])
537
+ # Every channel token in one lookup of a 1-D index, then one row per
538
+ # channel. A 0-d index per channel would also trip Intel Gaudi, whose
539
+ # embedding backward sends a 0-d index's gradient to row 0.
540
+ channel_tokens = self.channel_tokens(
541
+ self.index[n_channel_offset : n_channel_offset + n_chans]
542
+ )
526
543
  emb_seq = []
527
544
  token_masks = []
528
545
  for i in range(n_chans):
@@ -534,10 +551,9 @@ class _BIOTEncoder(nn.Module):
534
551
  batch_size, ts, _ = channel_spec_emb.shape
535
552
  # (batch_size, ts, emb)
536
553
  # Step by step the following lines do the following operations:
537
- # - self.channel_tokens(self.index[i + n_channel_offset]):
538
- # Fetches the embedding for a channel specified by i + n_channel_offset,
539
- # where i is the current index and n_channel_offset adjusts
540
- # which channel's embedding is retrieved.
554
+ # - channel_tokens[i]:
555
+ # The token of channel i + n_channel_offset, where
556
+ # n_channel_offset adjusts which channel's embedding is used.
541
557
  # - .unsqueeze(0).unsqueeze(0):
542
558
  # Adds two singleton dimensions to the embedding tensor.
543
559
  # [emb_size] to [1, 1, emb_size] .
@@ -545,10 +561,7 @@ class _BIOTEncoder(nn.Module):
545
561
  # Replicates the embedding tensor to match the batch size and
546
562
  # time steps (ts),
547
563
  channel_token_emb = (
548
- self.channel_tokens(self.index[i + n_channel_offset])
549
- .unsqueeze(0)
550
- .unsqueeze(0)
551
- .repeat(batch_size, ts, 1)
564
+ channel_tokens[i].unsqueeze(0).unsqueeze(0).repeat(batch_size, ts, 1)
552
565
  )
553
566
  # (batch_size, ts, emb)
554
567
  # The positional embedding is explaining with more
@@ -572,5 +585,4 @@ class _BIOTEncoder(nn.Module):
572
585
  token_mask: Optional[torch.Tensor] = None
573
586
  if ch_mask is not None:
574
587
  token_mask = torch.cat(token_masks, dim=1)
575
- # (batch_size, emb)
576
- return masked_mean(self.transformer(emb, token_mask), token_mask, [1])
588
+ return self.transformer(emb, token_mask), token_mask
@@ -17,7 +17,6 @@ import torchaudio as ta
17
17
  from torch import nn
18
18
  from torch.nn import functional as F
19
19
 
20
- from braindecode.functional.attention import _hpu_lazy
21
20
  from braindecode.models.base import EEGModuleMixin
22
21
  from braindecode.models.util import has_valid_locations, positions_from_chs_info
23
22
  from braindecode.modules import ChannelMerger
@@ -713,7 +712,7 @@ class _ConvSequence(nn.Module):
713
712
  nn.Conv1d(
714
713
  chout, 2 * chout, 1 + 2 * glu_context, padding=glu_context
715
714
  ),
716
- _GLU(dim=1),
715
+ nn.GLU(dim=1),
717
716
  )
718
717
  )
719
718
  else:
@@ -728,17 +727,6 @@ class _ConvSequence(nn.Module):
728
727
  return x
729
728
 
730
729
 
731
- class _GLU(nn.GLU):
732
- """``nn.GLU`` that Intel Gaudi's lazy mode can compile."""
733
-
734
- def forward(self, x: torch.Tensor) -> torch.Tensor:
735
- if not torch.jit.is_scripting() and x.device.type == "hpu" and _hpu_lazy():
736
- # Its graph compiler fails on ``aten.glu`` after a convolution.
737
- a, b = x.chunk(2, dim=self.dim)
738
- return a * torch.sigmoid(b)
739
- return F.glu(x, self.dim)
740
-
741
-
742
730
  def _pad_multiple(x: torch.Tensor, base: int) -> torch.Tensor:
743
731
  """Pad tensor to be a multiple of base."""
744
732
  length = x.shape[-1]
@@ -143,7 +143,9 @@ class CBraMod(EEGModuleMixin, nn.Module):
143
143
  activation : type[nn.Module], default=nn.GELU
144
144
  Activation function used in Transformer feedforward layers.
145
145
  emb_dim : int, default=200
146
- Output embedding dimension.
146
+ Output dimension of ``proj_out``, the pretraining reconstruction layer.
147
+ It is kept so the released weights load, but it is not applied: features
148
+ and head use the encoder output, of size ``d_model``.
147
149
  drop_prob : float, default=0.1
148
150
  Dropout probability.
149
151
  return_encoder_output : bool, default=False
@@ -227,7 +229,7 @@ class CBraMod(EEGModuleMixin, nn.Module):
227
229
  self.encoder = _TransformerEncoder(encoder_layer, num_layers=n_layer)
228
230
  self.proj_out = nn.Sequential(nn.Linear(d_model, emb_dim))
229
231
 
230
- self._emb_dim = emb_dim
232
+ self._d_model = d_model
231
233
  self._patch_size = patch_size
232
234
  self._encoder_output = return_encoder_output
233
235
  self._init_parameters()
@@ -236,7 +238,7 @@ class CBraMod(EEGModuleMixin, nn.Module):
236
238
  self.final_layer = nn.Identity()
237
239
  elif self._knows_geometry():
238
240
  n_patch = self._n_patch()
239
- flat_dim = self.n_chans * n_patch * emb_dim
241
+ flat_dim = self.n_chans * n_patch * d_model
240
242
  self.final_layer = nn.Sequential(
241
243
  nn.Flatten(), nn.Linear(flat_dim, self.n_outputs)
242
244
  )
@@ -253,7 +255,7 @@ class CBraMod(EEGModuleMixin, nn.Module):
253
255
  self._encoder_output = False
254
256
  if self._knows_geometry():
255
257
  n_patch = self._n_patch()
256
- flat_dim = self.n_chans * n_patch * self._emb_dim
258
+ flat_dim = self.n_chans * n_patch * self._d_model
257
259
  self.final_layer = nn.Sequential(
258
260
  nn.Flatten(), nn.Linear(flat_dim, n_outputs)
259
261
  )
@@ -312,7 +314,9 @@ class CBraMod(EEGModuleMixin, nn.Module):
312
314
  x = self.rearrange(x)
313
315
  patch_emb = self.patch_embedding(x, mask, ch_mask)
314
316
  feats = self.encoder(patch_emb, src_key_padding_mask=key_padding_mask)
315
- out = self.proj_out(feats)
317
+ # proj_out is the pretraining reconstruction layer: the original
318
+ # fine-tuning models replace it by nn.Identity(), so it is not run.
319
+ out = feats
316
320
  if ch_mask is not None:
317
321
  out = out.masked_fill(~ch_mask[:, :, None, None], 0.0)
318
322
  if return_features:
@@ -15,7 +15,6 @@ from torch import nn
15
15
  from torch.nn.utils.parametrizations import weight_norm
16
16
 
17
17
  from braindecode.functional import _real_dft, spectral_input
18
- from braindecode.functional.attention import _hpu_lazy
19
18
  from braindecode.functional.functions import _next_fast_len
20
19
  from braindecode.models.base import EEGModuleMixin
21
20
 
@@ -442,6 +441,9 @@ class _GConv(nn.Module):
442
441
  self.register_buffer(
443
442
  "kernel_norm_initialized", torch.tensor(0, dtype=torch.bool)
444
443
  )
444
+ # The buffer as a Python bool: torch.compile guards on it once instead
445
+ # of breaking the graph to read a tensor on every forward.
446
+ self._kernel_norm_ready = False
445
447
 
446
448
  # ========== Learnable parameters ==========
447
449
  self.skip_weight = nn.Parameter(torch.randn(channels, self.d_model))
@@ -475,6 +477,10 @@ class _GConv(nn.Module):
475
477
  )
476
478
  self.output_linear = nn.Linear(self.d_model * self.channels, self.d_model)
477
479
 
480
+ def _load_from_state_dict(self, state_dict, prefix, *args, **kwargs):
481
+ super()._load_from_state_dict(state_dict, prefix, *args, **kwargs)
482
+ self._kernel_norm_ready = bool(self.kernel_norm_initialized)
483
+
478
484
  def forward(
479
485
  self, x: torch.Tensor, return_kernel: bool = False
480
486
  ) -> Tuple[torch.Tensor, Optional[torch.Tensor]]:
@@ -505,11 +511,12 @@ class _GConv(nn.Module):
505
511
  # Lazy-init kernel normalisation on first forward pass
506
512
  # In place, so a first forward under torch.inference_mode() does not
507
513
  # leave inference tensors in the buffers for a later training step.
508
- if not self.kernel_norm_initialized:
514
+ if not self._kernel_norm_ready:
509
515
  self.kernel_norm.copy_(
510
516
  torch.linalg.vector_norm(kernel, 2, dim=-1, keepdim=True).detach()
511
517
  )
512
518
  self.kernel_norm_initialized.fill_(True)
519
+ self._kernel_norm_ready = True
513
520
 
514
521
  # Pad or truncate kernel to match seq_len
515
522
  if kernel.size(-1) > seq_len:
@@ -896,20 +903,10 @@ class _ResidualGroup(nn.Module):
896
903
  def forward(self, input_data: torch.Tensor) -> torch.Tensor:
897
904
  noise = input_data
898
905
  h = noise
899
- if not torch.jit.is_scripting() and h.device.type == "hpu" and _hpu_lazy():
900
- # Gaudi's lazy-mode graph compiler fails on the backward of the
901
- # sequential skip sum (one skip_conv dedw node lands in two
902
- # pipeline bundles); one n-ary stack-sum reduction compiles.
903
- skip_list = []
904
- for block in self.residual_blocks:
905
- h, skip_n = block((h, noise))
906
- skip_list.append(skip_n)
907
- skip = torch.stack(skip_list, dim=0).sum(dim=0)
908
- else:
909
- skip = torch.zeros((), dtype=h.dtype, device=h.device)
910
- for block in self.residual_blocks:
911
- h, skip_n = block((h, noise))
912
- skip = skip_n + skip
906
+ skip = torch.zeros((), dtype=h.dtype, device=h.device)
907
+ for block in self.residual_blocks:
908
+ h, skip_n = block((h, noise))
909
+ skip = skip_n + skip
913
910
 
914
911
  return skip * math.sqrt(1.0 / self.num_res_layers)
915
912
 
@@ -23,11 +23,7 @@ from braindecode.models.steegformer import (
23
23
  _TemporalPositionalEncoding,
24
24
  _TransformerEncoderBlock,
25
25
  )
26
- from braindecode.models.util import (
27
- extract_channel_locations_from_chs_info,
28
- has_valid_locations,
29
- valid_location_mask,
30
- )
26
+ from braindecode.models.util import chs_info_positions
31
27
  from braindecode.modules import PatchTokenizer
32
28
  from braindecode.util import resolve_montage_name
33
29
 
@@ -255,21 +251,7 @@ class CORTEG(EEGModuleMixin, nn.Module):
255
251
  self.merge_at = depth - n_merge_blocks
256
252
  self.knn_k = knn_k
257
253
 
258
- default_pos: Optional[torch.Tensor] = None
259
- chs_info = self._chs_info
260
- if has_valid_locations(chs_info):
261
- locations = extract_channel_locations_from_chs_info(
262
- chs_info, fill_missing=True
263
- )
264
- default_pos = torch.as_tensor(locations, dtype=torch.float32)
265
- unplaced = (~valid_location_mask(default_pos))[:, 0].tolist()
266
- if any(unplaced):
267
- names = [ch["ch_name"] for ch, u in zip(chs_info, unplaced) if u]
268
- raise ValueError(
269
- f"CORTEG places each electrode by its 3D position, but chs_info "
270
- f"has none for {names}; drop these channels, or pass pos at "
271
- "each call."
272
- )
254
+ default_pos = chs_info_positions(self._chs_info, "CORTEG")
273
255
  # Montage-specific, rebuilt from chs_info: not saved with the weights.
274
256
  self.register_buffer("default_pos", default_pos, persistent=False)
275
257
  self.register_buffer("vocab_positions", vocab_positions, persistent=False)
@@ -224,8 +224,10 @@ class CSBrain(EEGModuleMixin, nn.Module):
224
224
  activation : type[nn.Module], default=nn.GELU
225
225
  Activation function used in the encoder feedforward blocks.
226
226
  emb_dim : int, default=200
227
- Output dimension of the final projection applied to the encoder
228
- output.
227
+ Output dimension of ``proj_out``, the pretraining reconstruction layer.
228
+ It is kept so the released weights load, but it is not applied:
229
+ features use the encoder output, of size ``d_model`` (the patch size).
230
+ It still sets the hidden widths of the task head.
229
231
  temporal_kernel_sizes : tuple[int, ...], default=(1, 3, 5)
230
232
  Kernel sizes of the cross-scale temporal embedding convolutions.
231
233
  drop_prob : float, default=0.1
@@ -235,9 +237,8 @@ class CSBrain(EEGModuleMixin, nn.Module):
235
237
  Dropout probability of the task head. ``None`` uses ``drop_prob``.
236
238
  The reference fine-tuning models keep the backbone at 0.1 and set
237
239
  only the head dropout (``--dropout 0.3`` for BCIC IV-2a), and they
238
- replace ``proj_out`` by ``nn.Identity()`` after loading the
239
- pretrained weights: ``drop_prob=0.1, head_drop_prob=0.3``, then
240
- ``model.proj_out = nn.Identity()``.
240
+ skip ``proj_out`` (it is replaced by ``nn.Identity()`` there, and not
241
+ applied here): ``drop_prob=0.1, head_drop_prob=0.3``.
241
242
  brain_regions : sequence of int | None, default=None
242
243
  Explicit region id per input channel (0 frontal, 1 parietal, 2
243
244
  temporal, 3 occipital, 4 central), taking precedence over the
@@ -258,7 +259,7 @@ class CSBrain(EEGModuleMixin, nn.Module):
258
259
  (e.g. 800 for 4 s and 2000 for 10 s windows at 200 Hz). Some
259
260
  reference heads differ, e.g. SEED-V (1 s windows) uses 800; pass it
260
261
  here to load those checkpoints. The first head layer has
261
- ``n_chans * n_patch * emb_dim * head_hidden_dim`` weights, which grows
262
+ ``n_chans * n_patch * d_model * head_hidden_dim`` weights, which grows
262
263
  quadratically with the window length by default (about 2.3e9 for 64
263
264
  channels and 30 s), so set a smaller width for long windows.
264
265
  return_encoder_output : bool, default=False
@@ -446,7 +447,7 @@ class CSBrain(EEGModuleMixin, nn.Module):
446
447
 
447
448
  def _make_task_head(self) -> nn.Sequential:
448
449
  # Three-layer MLP head of the reference fine-tuning models: flatten
449
- # (chans, patches, emb_dim) -> n_patch * emb_dim -> emb_dim -> n_outputs.
450
+ # (chans, patches, d_model) -> n_patch * emb_dim -> emb_dim -> n_outputs.
450
451
  # n_chans / n_times may come from chs_info / input_window_seconds.
451
452
  # Without them the layers are lazy and the hidden width falls back to
452
453
  # 4 * emb_dim, the reference value for 4 s windows.
@@ -466,7 +467,7 @@ class CSBrain(EEGModuleMixin, nn.Module):
466
467
  hidden = self._head_hidden_dim or n_patch * self._emb_dim
467
468
  return nn.Sequential(
468
469
  nn.Flatten(),
469
- nn.Linear(n_chans * n_patch * self._emb_dim, hidden),
470
+ nn.Linear(n_chans * n_patch * self._d_model, hidden),
470
471
  nn.ELU(),
471
472
  nn.Dropout(self._head_drop_prob),
472
473
  nn.Linear(hidden, self._emb_dim),
@@ -508,7 +509,9 @@ class CSBrain(EEGModuleMixin, nn.Module):
508
509
  emb = self.temporal_embed(emb) + emb
509
510
  emb = self.region_embed(emb) + emb
510
511
  emb = layer(emb)
511
- out = self.proj_out(emb)
512
+ # proj_out is the pretraining reconstruction layer: the reference
513
+ # fine-tuning models replace it by nn.Identity(), so it is not run.
514
+ out = emb
512
515
  if return_features:
513
516
  features: Dict[str, Optional[Tensor]] = {"features": out, "cls_token": None}
514
517
  return features