Braindecode 1.3.2.dev183566201__tar.gz → 1.3.2.dev184103859__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.
- {braindecode-1.3.2.dev183566201/braindecode.egg-info → braindecode-1.3.2.dev184103859}/PKG-INFO +3 -3
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/bids/hub.py +2 -7
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/__init__.py +0 -2
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/base.py +97 -275
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/bendr.py +6 -17
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/biot.py +5 -23
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/cbramod.py +6 -28
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/config.py +29 -29
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/eeginception_mi.py +1 -2
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/eegitnet.py +3 -4
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/eegpt.py +2 -15
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/labram.py +1 -15
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/luna.py +21 -11
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/patchedtransformer.py +3 -5
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/reve.py +23 -59
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/shallow_fbcsp.py +8 -16
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/signal_jepa.py +13 -63
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/util.py +2 -133
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/modules/__init__.py +1 -2
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/modules/activation.py +0 -20
- braindecode-1.3.2.dev184103859/braindecode/version.py +1 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859/braindecode.egg-info}/PKG-INFO +3 -3
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode.egg-info/requires.txt +2 -2
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/conf.py +7 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/models/models_categorization.rst +1 -2
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/whats_new.rst +2 -54
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/pyproject.toml +2 -11
- braindecode-1.3.2.dev183566201/braindecode/version.py +0 -1
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/LICENSE.txt +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/MANIFEST.in +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/NOTICE.txt +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/README.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/__init__.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/augmentation/__init__.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/augmentation/base.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/augmentation/functional.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/augmentation/transforms.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/classifier.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/__init__.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/base.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/bbci.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/bcicomp.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/bids/__init__.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/bids/datasets.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/bids/format.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/bids/hub_format.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/bids/hub_io.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/bids/hub_validation.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/bids/iterable.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/chb_mit.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/mne.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/moabb.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/nmt.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/registry.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/siena.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/sleep_physio_challe_18.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/sleep_physionet.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/tuh.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/utils.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/xy.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datautil/__init__.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datautil/channel_utils.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datautil/hub_formats.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datautil/serialization.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datautil/util.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/eegneuralnet.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/functional/__init__.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/functional/functions.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/functional/initialization.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/atcnet.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/attentionbasenet.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/attn_sleep.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/brainmodule.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/contrawr.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/ctnet.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/deep4.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/deepsleepnet.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/dgcnn.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/eegconformer.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/eeginception_erp.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/eegminer.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/eegnet.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/eegnex.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/eegsimpleconv.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/eegsym.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/eegtcnet.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/fbcnet.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/fblightconvnet.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/fbmsnet.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/hybrid.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/ifnet.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/medformer.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/msvtnet.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/sccnet.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/sinc_shallow.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/sleep_stager_blanco_2020.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/sleep_stager_chambon_2018.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/sparcnet.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/sstdpn.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/summary.csv +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/syncnet.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/tcn.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/tidnet.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/tsinception.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/usleep.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/modules/attention.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/modules/blocks.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/modules/convolution.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/modules/filter.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/modules/layers.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/modules/linear.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/modules/parametrization.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/modules/stats.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/modules/util.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/modules/wrapper.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/preprocessing/__init__.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/preprocessing/eegprep_preprocess.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/preprocessing/mne_preprocess.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/preprocessing/preprocess.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/preprocessing/util.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/preprocessing/windowers.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/regressor.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/samplers/__init__.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/samplers/base.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/samplers/ssl.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/training/__init__.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/training/callbacks.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/training/losses.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/training/scoring.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/util.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/visualization/__init__.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/visualization/confusion_matrices.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/visualization/gradients.py +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode.egg-info/SOURCES.txt +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode.egg-info/dependency_links.txt +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode.egg-info/top_level.txt +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/Makefile +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/_templates/autosummary/class.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/_templates/autosummary/class_in_subdir.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/_templates/autosummary/function.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/_templates/autosummary/function_in_subdir.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/api.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/cite.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/help.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/index.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/install/install.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/install/install_pip.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/install/install_source.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/models/categorization/attention.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/models/categorization/channel.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/models/categorization/convolution.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/models/categorization/filterbank.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/models/categorization/gnn.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/models/categorization/interpretable.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/models/categorization/lbm.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/models/categorization/recurrent.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/models/categorization/spd.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/models/models.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/models/models_table.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/models/models_visualization.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/docs/sg_execution_times.rst +0 -0
- {braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/setup.cfg +0 -0
{braindecode-1.3.2.dev183566201/braindecode.egg-info → braindecode-1.3.2.dev184103859}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: braindecode
|
|
3
|
-
Version: 1.3.2.
|
|
3
|
+
Version: 1.3.2.dev184103859
|
|
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>
|
|
@@ -22,7 +22,7 @@ Requires-Python: >=3.11
|
|
|
22
22
|
Description-Content-Type: text/x-rst
|
|
23
23
|
License-File: LICENSE.txt
|
|
24
24
|
License-File: NOTICE.txt
|
|
25
|
-
Requires-Dist: torch>=2.
|
|
25
|
+
Requires-Dist: torch>=2.2
|
|
26
26
|
Requires-Dist: torchaudio>=2.0
|
|
27
27
|
Requires-Dist: mne>=1.11.0
|
|
28
28
|
Requires-Dist: pandas<3.0.0
|
|
@@ -35,7 +35,7 @@ Requires-Dist: wfdb
|
|
|
35
35
|
Requires-Dist: linear_attention_transformer
|
|
36
36
|
Requires-Dist: docstring_inheritance
|
|
37
37
|
Requires-Dist: rotary_embedding_torch
|
|
38
|
-
Requires-Dist:
|
|
38
|
+
Requires-Dist: pandas<3.0.0
|
|
39
39
|
Provides-Extra: moabb
|
|
40
40
|
Requires-Dist: moabb>=1.4.3; extra == "moabb"
|
|
41
41
|
Provides-Extra: eegprep
|
{braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/datasets/bids/hub.py
RENAMED
|
@@ -845,16 +845,11 @@ class HubDatasetMixin:
|
|
|
845
845
|
|
|
846
846
|
# Convert to MNE objects and create dataset
|
|
847
847
|
info = Info.from_json_dict(info_dict)
|
|
848
|
-
targets = metadata["target"].values
|
|
849
|
-
if np.issubdtype(targets.dtype, np.integer):
|
|
850
|
-
event_ids = targets
|
|
851
|
-
else:
|
|
852
|
-
event_ids = np.ones(len(metadata), dtype=int)
|
|
853
848
|
events = np.column_stack(
|
|
854
849
|
[
|
|
855
|
-
metadata["i_start_in_trial"].values
|
|
850
|
+
metadata["i_start_in_trial"].values,
|
|
856
851
|
np.zeros(len(metadata), dtype=int),
|
|
857
|
-
|
|
852
|
+
metadata["target"].values,
|
|
858
853
|
]
|
|
859
854
|
)
|
|
860
855
|
epochs = mne.EpochsArray(data, info, events=events, metadata=metadata)
|
{braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/__init__.py
RENAMED
|
@@ -55,7 +55,6 @@ from .tsinception import TSception
|
|
|
55
55
|
from .usleep import USleep
|
|
56
56
|
from .util import (
|
|
57
57
|
_init_models_dict,
|
|
58
|
-
build_model_config,
|
|
59
58
|
extract_channel_locations_from_chs_info,
|
|
60
59
|
models_mandatory_parameters,
|
|
61
60
|
)
|
|
@@ -119,7 +118,6 @@ __all__ = [
|
|
|
119
118
|
"TIDNet",
|
|
120
119
|
"TSception",
|
|
121
120
|
"USleep",
|
|
122
|
-
"build_model_config",
|
|
123
121
|
"_init_models_dict",
|
|
124
122
|
"models_mandatory_parameters",
|
|
125
123
|
]
|
{braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/base.py
RENAMED
|
@@ -17,13 +17,6 @@ from docstring_inheritance import NumpyDocstringInheritanceInitMeta
|
|
|
17
17
|
from mne.utils import _soft_import
|
|
18
18
|
from torchinfo import ModelStatistics, summary
|
|
19
19
|
|
|
20
|
-
from braindecode.models.util import (
|
|
21
|
-
_EEG_PARAMS,
|
|
22
|
-
_IMPORT_ADAPTER,
|
|
23
|
-
build_model_config,
|
|
24
|
-
resolve_type_kwargs,
|
|
25
|
-
track_model_init_kwargs,
|
|
26
|
-
)
|
|
27
20
|
from braindecode.version import __version__
|
|
28
21
|
|
|
29
22
|
huggingface_hub = _soft_import(
|
|
@@ -59,25 +52,7 @@ def deprecated_args(obj, *old_new_args):
|
|
|
59
52
|
return out_args
|
|
60
53
|
|
|
61
54
|
|
|
62
|
-
class
|
|
63
|
-
"""Defer ``__init__`` wrapping until after docstring inheritance.
|
|
64
|
-
|
|
65
|
-
``NumpyDocstringInheritanceInitMeta`` uses ``inspect.unwrap()``
|
|
66
|
-
internally, which bypasses ``@wraps`` wrappers. By wrapping
|
|
67
|
-
``__init__`` *after* docstring processing, the metaclass sees the
|
|
68
|
-
unwrapped function and correctly inherits ``cls.__doc__``.
|
|
69
|
-
"""
|
|
70
|
-
|
|
71
|
-
def __init__(cls, class_name, class_bases, class_dict):
|
|
72
|
-
super().__init__(class_name, class_bases, class_dict)
|
|
73
|
-
# Only wrap subclass __init__s, not EEGModuleMixin itself.
|
|
74
|
-
# Wrapping the mixin would cause super().__init__() calls to
|
|
75
|
-
# overwrite _braindecode_init_kwargs captured by the subclass.
|
|
76
|
-
if any(isinstance(b, _BraindecodeDocstringMeta) for b in class_bases):
|
|
77
|
-
track_model_init_kwargs(cls)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
|
|
55
|
+
class EEGModuleMixin(_BaseHubMixin, metaclass=NumpyDocstringInheritanceInitMeta):
|
|
81
56
|
"""
|
|
82
57
|
Mixin class for all EEG models in braindecode.
|
|
83
58
|
|
|
@@ -150,46 +125,24 @@ class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
|
|
|
150
125
|
# Load pretrained model
|
|
151
126
|
model = {name}.from_pretrained("username/my-{name_lower}-model")
|
|
152
127
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
..
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
features = out["features"]
|
|
166
|
-
|
|
167
|
-
# Replace the classification head
|
|
168
|
-
model.reset_head(n_outputs=10)
|
|
169
|
-
|
|
170
|
-
**Saving and restoring full configuration:**
|
|
171
|
-
|
|
172
|
-
.. code-block::
|
|
173
|
-
|
|
174
|
-
import json
|
|
175
|
-
|
|
176
|
-
config = model.get_config() # all __init__ params
|
|
177
|
-
with open("config.json", "w") as f:
|
|
178
|
-
json.dump(config, f)
|
|
179
|
-
|
|
180
|
-
model2 = {name}.from_config(config) # reconstruct (no weights)
|
|
181
|
-
|
|
182
|
-
All model parameters (both EEG-specific and model-specific such as
|
|
183
|
-
dropout rates, activation functions, number of filters) are automatically
|
|
184
|
-
saved to the Hub and restored when loading.
|
|
185
|
-
|
|
186
|
-
See :ref:`load-pretrained-models` for a complete tutorial.
|
|
128
|
+
The integration automatically handles EEG-specific parameters (n_chans,
|
|
129
|
+
n_times, sfreq, chs_info, etc.) by saving them in a config file alongside
|
|
130
|
+
the model weights. This ensures that loaded models are correctly configured
|
|
131
|
+
for their original data specifications.
|
|
132
|
+
|
|
133
|
+
.. important::
|
|
134
|
+
Currently, only EEG-specific parameters (n_outputs, n_chans, n_times,
|
|
135
|
+
input_window_seconds, sfreq, chs_info) are saved to the Hub.
|
|
136
|
+
Model-specific parameters (e.g., dropout rates, activation functions,
|
|
137
|
+
number of filters) are not preserved and will use their default values
|
|
138
|
+
when loading from the Hub.
|
|
139
|
+
Full parameter serialization will be addressed in a future update.
|
|
187
140
|
"""
|
|
188
141
|
|
|
189
142
|
def __init_subclass__(cls, **kwargs):
|
|
190
143
|
# Append model-specific Hub integration notes to the docstring.
|
|
191
|
-
# This runs
|
|
192
|
-
#
|
|
144
|
+
# This runs after the metaclass, so we concatenate rather than
|
|
145
|
+
# override any existing Notes section in the subclass.
|
|
193
146
|
if cls.__doc__ is not None:
|
|
194
147
|
hub_notes = cls._HUB_NOTES_TEMPLATE.format(
|
|
195
148
|
name=cls.__name__,
|
|
@@ -215,19 +168,6 @@ class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
|
|
|
215
168
|
repo_url = kwargs.pop("repo_url", "https://braindecode.org")
|
|
216
169
|
library_name = kwargs.pop("library_name", "braindecode")
|
|
217
170
|
license = kwargs.pop("license", "bsd-3-clause")
|
|
218
|
-
|
|
219
|
-
# Register a coder so that type[nn.Module] parameters
|
|
220
|
-
# (e.g. activation=nn.ELU) are serialized as importable
|
|
221
|
-
# strings in config.json and decoded back on load.
|
|
222
|
-
coders = kwargs.pop("coders", None) or {}
|
|
223
|
-
coders.setdefault(
|
|
224
|
-
type,
|
|
225
|
-
(
|
|
226
|
-
lambda t: f"{t.__module__}.{t.__qualname__}",
|
|
227
|
-
lambda data: _IMPORT_ADAPTER.validate_python(data),
|
|
228
|
-
),
|
|
229
|
-
)
|
|
230
|
-
|
|
231
171
|
# TODO: model_card_template can be added in the future for custom model cards
|
|
232
172
|
super().__init_subclass__(
|
|
233
173
|
tags=tags,
|
|
@@ -235,7 +175,6 @@ class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
|
|
|
235
175
|
repo_url=repo_url,
|
|
236
176
|
library_name=library_name,
|
|
237
177
|
license=license,
|
|
238
|
-
coders=coders,
|
|
239
178
|
**kwargs,
|
|
240
179
|
)
|
|
241
180
|
|
|
@@ -277,17 +216,6 @@ class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
|
|
|
277
216
|
self._n_times = n_times # type: ignore[assignment]
|
|
278
217
|
self._sfreq = sfreq # type: ignore[assignment]
|
|
279
218
|
|
|
280
|
-
# Back-fill instance attributes from _hub_mixin_config for any
|
|
281
|
-
# params the subclass didn't store on self. Skip EEG params
|
|
282
|
-
# (stored as self._*) and descriptors (properties).
|
|
283
|
-
for key, val in getattr(self, "_hub_mixin_config", {}).items():
|
|
284
|
-
if key in _EEG_PARAMS:
|
|
285
|
-
continue
|
|
286
|
-
if hasattr(getattr(type(self), key, None), "__get__"):
|
|
287
|
-
continue
|
|
288
|
-
if not hasattr(self, key):
|
|
289
|
-
setattr(self, key, val)
|
|
290
|
-
|
|
291
219
|
super().__init__()
|
|
292
220
|
|
|
293
221
|
@property
|
|
@@ -398,104 +326,6 @@ class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
|
|
|
398
326
|
raise ValueError(msg) from exc
|
|
399
327
|
raise exc
|
|
400
328
|
|
|
401
|
-
def get_config(self) -> dict:
|
|
402
|
-
"""Return a JSON-serializable dict of all ``__init__`` parameters.
|
|
403
|
-
|
|
404
|
-
The returned dictionary can be saved to a JSON file and later
|
|
405
|
-
used with :meth:`from_config` to reconstruct the model (without
|
|
406
|
-
weights). It is also used internally by :meth:`push_to_hub` to
|
|
407
|
-
persist the full model configuration.
|
|
408
|
-
|
|
409
|
-
Returns
|
|
410
|
-
-------
|
|
411
|
-
dict
|
|
412
|
-
All ``__init__`` parameters, JSON-serializable.
|
|
413
|
-
``type[nn.Module]`` parameters (e.g. ``activation``) are
|
|
414
|
-
encoded as importable dotted-path strings.
|
|
415
|
-
|
|
416
|
-
Examples
|
|
417
|
-
--------
|
|
418
|
-
>>> import json
|
|
419
|
-
>>> from braindecode.models import EEGNet
|
|
420
|
-
>>> model = EEGNet(n_chans=22, n_times=1000, n_outputs=4, F1=16)
|
|
421
|
-
>>> config = model.get_config()
|
|
422
|
-
>>> config["F1"]
|
|
423
|
-
16
|
|
424
|
-
>>> # Save to disk
|
|
425
|
-
>>> with open("config.json", "w") as f:
|
|
426
|
-
... json.dump(config, f)
|
|
427
|
-
|
|
428
|
-
.. versionadded:: 1.4
|
|
429
|
-
"""
|
|
430
|
-
return build_model_config(self)
|
|
431
|
-
|
|
432
|
-
@classmethod
|
|
433
|
-
def from_config(cls, config: dict) -> "EEGModuleMixin":
|
|
434
|
-
"""Create a model instance from a configuration dict.
|
|
435
|
-
|
|
436
|
-
This is the inverse of :meth:`get_config`. Weights are **not**
|
|
437
|
-
loaded -- use :meth:`from_pretrained` for that.
|
|
438
|
-
|
|
439
|
-
Parameters
|
|
440
|
-
----------
|
|
441
|
-
config : dict
|
|
442
|
-
Configuration dict as returned by :meth:`get_config`.
|
|
443
|
-
|
|
444
|
-
Returns
|
|
445
|
-
-------
|
|
446
|
-
EEGModuleMixin
|
|
447
|
-
A new model instance.
|
|
448
|
-
|
|
449
|
-
Examples
|
|
450
|
-
--------
|
|
451
|
-
>>> import json
|
|
452
|
-
>>> from braindecode.models import EEGNet
|
|
453
|
-
>>> model = EEGNet(n_chans=22, n_times=1000, n_outputs=4, F1=16)
|
|
454
|
-
>>> config = model.get_config()
|
|
455
|
-
>>> # Reconstruct (without weights)
|
|
456
|
-
>>> model2 = EEGNet.from_config(config)
|
|
457
|
-
>>> model2.F1
|
|
458
|
-
16
|
|
459
|
-
>>> # Or from a JSON file
|
|
460
|
-
>>> with open("config.json") as f:
|
|
461
|
-
... config = json.load(f)
|
|
462
|
-
>>> model3 = EEGNet.from_config(config)
|
|
463
|
-
|
|
464
|
-
.. versionadded:: 1.4
|
|
465
|
-
"""
|
|
466
|
-
config = dict(config) # shallow copy
|
|
467
|
-
config.pop("braindecode_version", None)
|
|
468
|
-
resolve_type_kwargs(cls, config)
|
|
469
|
-
return cls(**config)
|
|
470
|
-
|
|
471
|
-
def reset_head(self, n_outputs):
|
|
472
|
-
"""Replace the classification head for a new number of outputs.
|
|
473
|
-
|
|
474
|
-
This is called automatically by :meth:`from_pretrained` when the
|
|
475
|
-
user passes an ``n_outputs`` that differs from the saved config.
|
|
476
|
-
Override in subclasses that need a model-specific head structure.
|
|
477
|
-
|
|
478
|
-
Parameters
|
|
479
|
-
----------
|
|
480
|
-
n_outputs : int
|
|
481
|
-
New number of output classes.
|
|
482
|
-
|
|
483
|
-
Examples
|
|
484
|
-
--------
|
|
485
|
-
>>> from braindecode.models import BENDR
|
|
486
|
-
>>> model = BENDR(n_chans=22, n_times=1000, n_outputs=4)
|
|
487
|
-
>>> model.reset_head(10)
|
|
488
|
-
>>> model.n_outputs
|
|
489
|
-
10
|
|
490
|
-
|
|
491
|
-
.. versionadded:: 1.4
|
|
492
|
-
"""
|
|
493
|
-
raise NotImplementedError(
|
|
494
|
-
f"{type(self).__name__} does not implement reset_head(). "
|
|
495
|
-
"Override this method to support changing n_outputs after "
|
|
496
|
-
"loading pretrained weights."
|
|
497
|
-
)
|
|
498
|
-
|
|
499
329
|
mapping: Optional[Dict[str, str]] = None
|
|
500
330
|
|
|
501
331
|
def load_state_dict(self, state_dict, *args, **kwargs):
|
|
@@ -600,22 +430,54 @@ class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
|
|
|
600
430
|
|
|
601
431
|
@staticmethod
|
|
602
432
|
def _serialize_chs_info(chs_info):
|
|
603
|
-
"""
|
|
433
|
+
"""
|
|
434
|
+
Serialize MNE channel info to JSON-compatible format.
|
|
435
|
+
|
|
436
|
+
Parameters
|
|
437
|
+
----------
|
|
438
|
+
chs_info : list of dict or None
|
|
439
|
+
Channel information from MNE Info object.
|
|
440
|
+
|
|
441
|
+
Returns
|
|
442
|
+
-------
|
|
443
|
+
list of dict or None
|
|
444
|
+
Serialized channel information that can be saved to JSON.
|
|
445
|
+
"""
|
|
604
446
|
if chs_info is None:
|
|
605
447
|
return None
|
|
606
|
-
|
|
607
|
-
_FLOAT_FIELDS = ("cal", "range")
|
|
448
|
+
|
|
608
449
|
serialized = []
|
|
609
450
|
for ch in chs_info:
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
451
|
+
# Extract serializable fields from MNE channel info
|
|
452
|
+
ch_dict = {
|
|
453
|
+
"ch_name": ch.get("ch_name", ""),
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
# Handle kind field - can be either string or integer
|
|
457
|
+
kind_val = ch.get("kind")
|
|
458
|
+
if kind_val is not None:
|
|
459
|
+
ch_dict["kind"] = (
|
|
460
|
+
kind_val if isinstance(kind_val, str) else int(kind_val)
|
|
461
|
+
)
|
|
462
|
+
|
|
463
|
+
# Add numeric fields with safe conversion
|
|
464
|
+
coil_type = ch.get("coil_type")
|
|
465
|
+
if coil_type is not None:
|
|
466
|
+
ch_dict["coil_type"] = int(coil_type)
|
|
467
|
+
|
|
468
|
+
unit = ch.get("unit")
|
|
469
|
+
if unit is not None:
|
|
470
|
+
ch_dict["unit"] = int(unit)
|
|
471
|
+
|
|
472
|
+
cal = ch.get("cal")
|
|
473
|
+
if cal is not None:
|
|
474
|
+
ch_dict["cal"] = float(cal)
|
|
475
|
+
|
|
476
|
+
range_val = ch.get("range")
|
|
477
|
+
if range_val is not None:
|
|
478
|
+
ch_dict["range"] = float(range_val)
|
|
479
|
+
|
|
480
|
+
# Serialize location array if present
|
|
619
481
|
if "loc" in ch and ch["loc"] is not None:
|
|
620
482
|
ch_dict["loc"] = (
|
|
621
483
|
ch["loc"].tolist()
|
|
@@ -623,19 +485,35 @@ class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
|
|
|
623
485
|
else list(ch["loc"])
|
|
624
486
|
)
|
|
625
487
|
serialized.append(ch_dict)
|
|
488
|
+
|
|
626
489
|
return serialized
|
|
627
490
|
|
|
628
491
|
@staticmethod
|
|
629
492
|
def _deserialize_chs_info(chs_info_dict):
|
|
630
|
-
"""
|
|
493
|
+
"""
|
|
494
|
+
Deserialize channel info from JSON-compatible format to MNE-like structure.
|
|
495
|
+
|
|
496
|
+
Parameters
|
|
497
|
+
----------
|
|
498
|
+
chs_info_dict : list of dict or None
|
|
499
|
+
Serialized channel information.
|
|
500
|
+
|
|
501
|
+
Returns
|
|
502
|
+
-------
|
|
503
|
+
list of dict or None
|
|
504
|
+
Deserialized channel information compatible with MNE.
|
|
505
|
+
"""
|
|
631
506
|
if chs_info_dict is None:
|
|
632
507
|
return None
|
|
508
|
+
|
|
633
509
|
deserialized = []
|
|
634
510
|
for ch_dict in chs_info_dict:
|
|
635
511
|
ch = ch_dict.copy()
|
|
512
|
+
# Convert location back to numpy array if present
|
|
636
513
|
if "loc" in ch and ch["loc"] is not None:
|
|
637
514
|
ch["loc"] = np.array(ch["loc"])
|
|
638
515
|
deserialized.append(ch)
|
|
516
|
+
|
|
639
517
|
return deserialized
|
|
640
518
|
|
|
641
519
|
def _save_pretrained(self, save_directory):
|
|
@@ -655,8 +533,16 @@ class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
|
|
|
655
533
|
|
|
656
534
|
save_directory = Path(save_directory)
|
|
657
535
|
|
|
658
|
-
|
|
659
|
-
config
|
|
536
|
+
# Collect EEG-specific configuration
|
|
537
|
+
config = {
|
|
538
|
+
"n_outputs": self._n_outputs,
|
|
539
|
+
"n_chans": self._n_chans,
|
|
540
|
+
"n_times": self._n_times,
|
|
541
|
+
"input_window_seconds": self._input_window_seconds,
|
|
542
|
+
"sfreq": self._sfreq,
|
|
543
|
+
"chs_info": self._serialize_chs_info(self._chs_info),
|
|
544
|
+
"braindecode_version": __version__,
|
|
545
|
+
}
|
|
660
546
|
|
|
661
547
|
# Save to config.json
|
|
662
548
|
config_path = save_directory / "config.json"
|
|
@@ -695,78 +581,14 @@ class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
|
|
|
695
581
|
**model_kwargs,
|
|
696
582
|
):
|
|
697
583
|
model_kwargs.pop("braindecode_version", None)
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
config_file = huggingface_hub.hf_hub_download(
|
|
710
|
-
repo_id=model_id,
|
|
711
|
-
filename="config.json",
|
|
712
|
-
revision=revision,
|
|
713
|
-
cache_dir=cache_dir,
|
|
714
|
-
force_download=force_download,
|
|
715
|
-
token=token,
|
|
716
|
-
local_files_only=local_files_only,
|
|
717
|
-
)
|
|
718
|
-
with open(config_file, "r") as f:
|
|
719
|
-
saved_n_outputs = json.load(f).get("n_outputs")
|
|
720
|
-
except (OSError, json.JSONDecodeError, KeyError):
|
|
721
|
-
pass # config unavailable; skip reset_head logic
|
|
722
|
-
|
|
723
|
-
requested_n_outputs = model_kwargs.get("n_outputs")
|
|
724
|
-
|
|
725
|
-
# If the user requests different n_outputs, load with the
|
|
726
|
-
# saved value first (so weights match), then swap the head.
|
|
727
|
-
if (
|
|
728
|
-
saved_n_outputs is not None
|
|
729
|
-
and requested_n_outputs is not None
|
|
730
|
-
and requested_n_outputs != saved_n_outputs
|
|
731
|
-
):
|
|
732
|
-
model_kwargs["n_outputs"] = saved_n_outputs
|
|
733
|
-
|
|
734
|
-
# If a custom filename is provided, temporarily override the
|
|
735
|
-
# HuggingFace constant so the parent class downloads the
|
|
736
|
-
# correct file (e.g. "LUNA_base.safetensors" instead of
|
|
737
|
-
# "model.safetensors").
|
|
738
|
-
hf_constants = huggingface_hub.constants
|
|
739
|
-
_orig_safetensors = hf_constants.SAFETENSORS_SINGLE_FILE
|
|
740
|
-
if filename is not None:
|
|
741
|
-
hf_constants.SAFETENSORS_SINGLE_FILE = filename
|
|
742
|
-
try:
|
|
743
|
-
model = super()._from_pretrained( # type: ignore
|
|
744
|
-
model_id=model_id,
|
|
745
|
-
revision=revision,
|
|
746
|
-
cache_dir=cache_dir,
|
|
747
|
-
force_download=force_download,
|
|
748
|
-
local_files_only=local_files_only,
|
|
749
|
-
token=token,
|
|
750
|
-
map_location=map_location,
|
|
751
|
-
strict=strict,
|
|
752
|
-
**model_kwargs,
|
|
753
|
-
)
|
|
754
|
-
finally:
|
|
755
|
-
hf_constants.SAFETENSORS_SINGLE_FILE = _orig_safetensors
|
|
756
|
-
|
|
757
|
-
if (
|
|
758
|
-
saved_n_outputs is not None
|
|
759
|
-
and requested_n_outputs is not None
|
|
760
|
-
and requested_n_outputs != saved_n_outputs
|
|
761
|
-
):
|
|
762
|
-
try:
|
|
763
|
-
model.reset_head(requested_n_outputs)
|
|
764
|
-
except NotImplementedError:
|
|
765
|
-
raise ValueError(
|
|
766
|
-
f"{type(model).__name__} does not support changing "
|
|
767
|
-
f"n_outputs after loading. Saved model has "
|
|
768
|
-
f"n_outputs={saved_n_outputs}, but "
|
|
769
|
-
f"n_outputs={requested_n_outputs} was requested."
|
|
770
|
-
) from None
|
|
771
|
-
|
|
772
|
-
return model
|
|
584
|
+
return super()._from_pretrained( # type: ignore
|
|
585
|
+
model_id=model_id,
|
|
586
|
+
revision=revision,
|
|
587
|
+
cache_dir=cache_dir,
|
|
588
|
+
force_download=force_download,
|
|
589
|
+
local_files_only=local_files_only,
|
|
590
|
+
token=token,
|
|
591
|
+
map_location=map_location,
|
|
592
|
+
strict=strict,
|
|
593
|
+
**model_kwargs,
|
|
594
|
+
)
|
{braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/bendr.py
RENAMED
|
@@ -291,23 +291,15 @@ class BENDR(EEGModuleMixin, nn.Module):
|
|
|
291
291
|
else:
|
|
292
292
|
in_features = encoder_h
|
|
293
293
|
|
|
294
|
-
self._head_in_features = in_features
|
|
295
294
|
self.final_layer = None
|
|
296
295
|
if self.include_final_layer:
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
linear, name="weight", dim=1
|
|
303
|
-
)
|
|
304
|
-
|
|
305
|
-
def reset_head(self, n_outputs):
|
|
306
|
-
self._n_outputs = n_outputs
|
|
307
|
-
self.include_final_layer = True
|
|
308
|
-
self._build_head(n_outputs)
|
|
296
|
+
# in_features: encoder_h*4 (encoder_only) or encoder_h (full model)
|
|
297
|
+
linear = nn.Linear(in_features=in_features, out_features=self.n_outputs)
|
|
298
|
+
self.final_layer = nn.utils.parametrizations.weight_norm(
|
|
299
|
+
linear, name="weight", dim=1
|
|
300
|
+
)
|
|
309
301
|
|
|
310
|
-
def forward(self, x
|
|
302
|
+
def forward(self, x):
|
|
311
303
|
if self.channel_projection is not None:
|
|
312
304
|
x = self.channel_projection(x)
|
|
313
305
|
encoded = self.encoder(x)
|
|
@@ -336,9 +328,6 @@ class BENDR(EEGModuleMixin, nn.Module):
|
|
|
336
328
|
feature = context[:, :, 0]
|
|
337
329
|
# feature: [batch_size, encoder_h]
|
|
338
330
|
|
|
339
|
-
if return_features:
|
|
340
|
-
return {"features": feature, "cls_token": None}
|
|
341
|
-
|
|
342
331
|
if self.final_layer is not None:
|
|
343
332
|
feature = self.final_layer(feature)
|
|
344
333
|
# feature: [batch_size, n_outputs]
|
{braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/biot.py
RENAMED
|
@@ -183,22 +183,13 @@ class BIOT(EEGModuleMixin, nn.Module):
|
|
|
183
183
|
attn_layer_dropout=att_layer_drop_prob,
|
|
184
184
|
)
|
|
185
185
|
|
|
186
|
-
self._head_activation = activation
|
|
187
186
|
self.final_layer = _ClassificationHead(
|
|
188
187
|
emb_size=self.embed_dim,
|
|
189
188
|
n_outputs=self.n_outputs,
|
|
190
189
|
activation=activation,
|
|
191
190
|
)
|
|
192
191
|
|
|
193
|
-
def
|
|
194
|
-
self._n_outputs = n_outputs
|
|
195
|
-
self.final_layer = _ClassificationHead(
|
|
196
|
-
emb_size=self.embed_dim,
|
|
197
|
-
n_outputs=n_outputs,
|
|
198
|
-
activation=self._head_activation,
|
|
199
|
-
)
|
|
200
|
-
|
|
201
|
-
def forward(self, x, return_features=False):
|
|
192
|
+
def forward(self, x):
|
|
202
193
|
"""
|
|
203
194
|
Pass the input through the BIOT encoder, and then through the
|
|
204
195
|
classification head.
|
|
@@ -207,24 +198,15 @@ class BIOT(EEGModuleMixin, nn.Module):
|
|
|
207
198
|
----------
|
|
208
199
|
x: Tensor
|
|
209
200
|
(batch_size, n_channels, n_times)
|
|
210
|
-
return_features : bool
|
|
211
|
-
If True, return a dict with ``"features"`` and ``"cls_token"``
|
|
212
|
-
instead of the classification output.
|
|
213
201
|
|
|
214
202
|
Returns
|
|
215
203
|
-------
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
If legacy ``return_feature=True`` (init param):
|
|
221
|
-
``(out, emb)`` tuple (ignored when ``return_features=True``).
|
|
204
|
+
out: Tensor
|
|
205
|
+
(batch_size, n_outputs)
|
|
206
|
+
(out, emb): tuple Tensor
|
|
207
|
+
(batch_size, n_outputs), (batch_size, emb_size)
|
|
222
208
|
"""
|
|
223
209
|
emb = self.encoder(x)
|
|
224
|
-
|
|
225
|
-
if return_features:
|
|
226
|
-
return {"features": emb, "cls_token": None}
|
|
227
|
-
|
|
228
210
|
x = self.final_layer(emb)
|
|
229
211
|
|
|
230
212
|
if self.return_feature:
|
{braindecode-1.3.2.dev183566201 → braindecode-1.3.2.dev184103859}/braindecode/models/cbramod.py
RENAMED
|
@@ -205,33 +205,13 @@ class CBraMod(EEGModuleMixin, nn.Module):
|
|
|
205
205
|
self.encoder = _TransformerEncoder(encoder_layer, num_layers=n_layer)
|
|
206
206
|
self.proj_out = nn.Sequential(nn.Linear(d_model, emb_dim))
|
|
207
207
|
|
|
208
|
-
self._emb_dim = emb_dim
|
|
209
|
-
self._patch_size = patch_size
|
|
210
208
|
self._weights_init()
|
|
211
209
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
self.final_layer = nn.Sequential(
|
|
218
|
-
nn.Flatten(), nn.Linear(flat_dim, self.n_outputs)
|
|
219
|
-
)
|
|
220
|
-
else:
|
|
221
|
-
self.final_layer = nn.Sequential(
|
|
222
|
-
nn.Flatten(), nn.LazyLinear(self.n_outputs)
|
|
223
|
-
)
|
|
224
|
-
|
|
225
|
-
def reset_head(self, n_outputs):
|
|
226
|
-
self._n_outputs = n_outputs
|
|
227
|
-
if self._n_times is not None and self._n_chans is not None:
|
|
228
|
-
n_patch = self._n_times // self._patch_size
|
|
229
|
-
flat_dim = self._n_chans * n_patch * self._emb_dim
|
|
230
|
-
self.final_layer = nn.Sequential(
|
|
231
|
-
nn.Flatten(), nn.Linear(flat_dim, n_outputs)
|
|
232
|
-
)
|
|
233
|
-
else:
|
|
234
|
-
self.final_layer = nn.Sequential(nn.Flatten(), nn.LazyLinear(n_outputs))
|
|
210
|
+
self.final_layer = (
|
|
211
|
+
nn.Identity()
|
|
212
|
+
if return_encoder_output
|
|
213
|
+
else nn.Sequential(nn.Flatten(), nn.LazyLinear(self.n_outputs))
|
|
214
|
+
)
|
|
235
215
|
|
|
236
216
|
def _weights_init(self):
|
|
237
217
|
for m in self.modules():
|
|
@@ -243,13 +223,11 @@ class CBraMod(EEGModuleMixin, nn.Module):
|
|
|
243
223
|
nn.init.constant_(m.weight, 1)
|
|
244
224
|
nn.init.constant_(m.bias, 0)
|
|
245
225
|
|
|
246
|
-
def forward(self, x, mask=None
|
|
226
|
+
def forward(self, x, mask=None):
|
|
247
227
|
x = self.rearrange(x)
|
|
248
228
|
patch_emb = self.patch_embedding(x, mask)
|
|
249
229
|
feats = self.encoder(patch_emb)
|
|
250
230
|
out = self.proj_out(feats)
|
|
251
|
-
if return_features:
|
|
252
|
-
return {"features": out, "cls_token": None}
|
|
253
231
|
return self.final_layer(out)
|
|
254
232
|
|
|
255
233
|
|