-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa7bf3c
commit a172f9c
Showing
69 changed files
with
1,066 additions
and
1,214 deletions.
There are no files selected for viewing
Binary file modified
BIN
-950 Bytes
(99%)
docs/_downloads/07fcc19ba03226cd3d83d4e40ec44385/auto_examples_python.zip
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ | |
}, | ||
"outputs": [], | ||
"source": [ | ||
"# Authors: Igor Carrara <[email protected]>\n# Bruno Aristimunha <[email protected]>\n#\n# License: BSD (3-clause)\n\nimport matplotlib.pyplot as plt\nimport mne\nimport seaborn as sns\nimport torch\nfrom braindecode import EEGClassifier\nfrom braindecode.models import EEGNetv4\nfrom sklearn.pipeline import Pipeline\nfrom skorch.callbacks import EarlyStopping, EpochScoring\nfrom skorch.dataset import ValidSplit\n\nfrom moabb.datasets import BNCI2014_001\nfrom moabb.evaluations import CrossSessionEvaluation\nfrom moabb.paradigms import MotorImagery\nfrom moabb.pipelines.utils_pytorch import BraindecodeDatasetLoader, InputShapeSetterEEG\nfrom moabb.utils import setup_seed\n\n\nmne.set_log_level(False)\n\n# Print Information PyTorch\nprint(f\"Torch Version: {torch.__version__}\")\n\n# Set up GPU if it is there\ncuda = torch.cuda.is_available()\ndevice = \"cuda\" if cuda else \"cpu\"\nprint(\"GPU is\", \"AVAILABLE\" if cuda else \"NOT AVAILABLE\")" | ||
"# Authors: Igor Carrara <[email protected]>\n# Bruno Aristimunha <[email protected]>\n#\n# License: BSD (3-clause)\n\nimport matplotlib.pyplot as plt\nimport mne\nimport seaborn as sns\nimport torch\nfrom braindecode import EEGClassifier\nfrom braindecode.models import EEGNetv4\nfrom sklearn.pipeline import make_pipeline\nfrom skorch.callbacks import EarlyStopping, EpochScoring\nfrom skorch.dataset import ValidSplit\n\nfrom moabb.datasets import BNCI2014_001\nfrom moabb.evaluations import CrossSessionEvaluation\nfrom moabb.paradigms import MotorImagery\nfrom moabb.utils import setup_seed\n\n\nmne.set_log_level(False)\n\n# Print Information PyTorch\nprint(f\"Torch Version: {torch.__version__}\")\n\n# Set up GPU if it is there\ncuda = torch.cuda.is_available()\ndevice = \"cuda\" if cuda else \"cpu\"\nprint(\"GPU is\", \"AVAILABLE\" if cuda else \"NOT AVAILABLE\")" | ||
] | ||
}, | ||
{ | ||
|
@@ -44,7 +44,7 @@ | |
}, | ||
"outputs": [], | ||
"source": [ | ||
"# Set random seed to be able to reproduce results\nseed = 42\nsetup_seed(seed)\n\n# Ensure that all operations are deterministic on GPU (if used) for reproducibility\ntorch.backends.cudnn.deterministic = True\ntorch.backends.cudnn.benchmark = False\n\n# Hyperparameter\nLEARNING_RATE = 0.0625 * 0.01 # parameter taken from Braindecode\nWEIGHT_DECAY = 0 # parameter taken from Braindecode\nBATCH_SIZE = 64 # parameter taken from BrainDecode\nEPOCH = 10\nPATIENCE = 3\nfmin = 4\nfmax = 100\ntmin = 0\ntmax = None\n\n# Load the dataset\ndataset = BNCI2014_001()\nevents = [\"right_hand\", \"left_hand\"]\nparadigm = MotorImagery(\n events=events, n_classes=len(events), fmin=fmin, fmax=fmax, tmin=tmin, tmax=tmax\n)\nsubjects = [1]\nX, _, _ = paradigm.get_data(dataset=dataset, subjects=subjects)\n# Define Transformer of Dataset compatible with Brain Decode\ncreate_dataset = BraindecodeDatasetLoader()" | ||
"# Set random seed to be able to reproduce results\nseed = 42\nsetup_seed(seed)\n\n# Ensure that all operations are deterministic on GPU (if used) for reproducibility\ntorch.backends.cudnn.deterministic = True\ntorch.backends.cudnn.benchmark = False\n\n# Hyperparameter\nLEARNING_RATE = 0.0625 * 0.01 # parameter taken from Braindecode\nWEIGHT_DECAY = 0 # parameter taken from Braindecode\nBATCH_SIZE = 64 # parameter taken from BrainDecode\nEPOCH = 10\nPATIENCE = 3\nfmin = 4\nfmax = 100\ntmin = 0\ntmax = None\n\n# Load the dataset\ndataset = BNCI2014_001()\nevents = [\"right_hand\", \"left_hand\"]\nparadigm = MotorImagery(\n events=events, n_classes=len(events), fmin=fmin, fmax=fmax, tmin=tmin, tmax=tmax\n)\nsubjects = [1]\nX, _, _ = paradigm.get_data(dataset=dataset, subjects=subjects)" | ||
] | ||
}, | ||
{ | ||
|
@@ -62,7 +62,7 @@ | |
}, | ||
"outputs": [], | ||
"source": [ | ||
"model = EEGNetv4(in_chans=1, n_classes=1, input_window_samples=100)\n\n# Send model to GPU\nif cuda:\n model.cuda()\n\n# Define a Skorch classifier\nclf = EEGClassifier(\n module=model,\n criterion=torch.nn.CrossEntropyLoss,\n optimizer=torch.optim.Adam,\n optimizer__lr=LEARNING_RATE,\n batch_size=BATCH_SIZE,\n max_epochs=EPOCH,\n train_split=ValidSplit(0.2, random_state=seed),\n device=device,\n callbacks=[\n EarlyStopping(monitor=\"valid_loss\", patience=PATIENCE),\n EpochScoring(\n scoring=\"accuracy\", on_train=True, name=\"train_acc\", lower_is_better=False\n ),\n EpochScoring(\n scoring=\"accuracy\", on_train=False, name=\"valid_acc\", lower_is_better=False\n ),\n InputShapeSetterEEG(\n params_list=[\"in_chans\", \"input_window_samples\", \"n_classes\"],\n ),\n ],\n verbose=1, # Not printing the results for each epoch\n)\n\n# Create the pipelines\npipes = {}\npipes[\"EEGNetV4\"] = Pipeline([(\"Braindecode_dataset\", create_dataset), (\"Net\", clf)])" | ||
"# Define a Skorch classifier\nclf = EEGClassifier(\n module=EEGNetv4,\n optimizer=torch.optim.Adam,\n optimizer__lr=LEARNING_RATE,\n batch_size=BATCH_SIZE,\n max_epochs=EPOCH,\n train_split=ValidSplit(0.2, random_state=seed),\n device=device,\n callbacks=[\n EarlyStopping(monitor=\"valid_loss\", patience=PATIENCE),\n EpochScoring(\n scoring=\"accuracy\", on_train=True, name=\"train_acc\", lower_is_better=False\n ),\n EpochScoring(\n scoring=\"accuracy\", on_train=False, name=\"valid_acc\", lower_is_better=False\n ),\n ],\n verbose=1, # Not printing the results for each epoch\n)\n\n# Create the pipelines\npipes = {}\npipes[\"EEGNetV4\"] = make_pipeline(clf)" | ||
] | ||
}, | ||
{ | ||
|
Binary file modified
BIN
-994 Bytes
(99%)
docs/_downloads/6f1e7a639e0699d6164445b55e6c116d/auto_examples_jupyter.zip
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ | |
}, | ||
"outputs": [], | ||
"source": [ | ||
"# Authors: Igor Carrara <[email protected]>\n#\n# License: BSD (3-clause)\n\nfrom pickle import load\n\nimport keras\nimport torch\nfrom braindecode import EEGClassifier\nfrom braindecode.models import EEGInception\nfrom scikeras.wrappers import KerasClassifier\nfrom sklearn.pipeline import Pipeline\nfrom skorch.callbacks import EarlyStopping, EpochScoring\nfrom skorch.dataset import ValidSplit\n\nfrom moabb import set_log_level\nfrom moabb.pipelines.features import StandardScaler_Epoch\nfrom moabb.pipelines.utils_pytorch import BraindecodeDatasetLoader, InputShapeSetterEEG\nfrom moabb.utils import setup_seed\n\n\nset_log_level(\"info\")" | ||
"# Authors: Igor Carrara <[email protected]>\n#\n# License: BSD (3-clause)\n\nfrom pickle import load\n\nimport keras\nimport torch\nfrom braindecode import EEGClassifier\nfrom braindecode.models import EEGInception\nfrom scikeras.wrappers import KerasClassifier\nfrom sklearn.pipeline import Pipeline, make_pipeline\nfrom skorch.callbacks import EarlyStopping, EpochScoring\nfrom skorch.dataset import ValidSplit\n\nfrom moabb import set_log_level\nfrom moabb.pipelines.features import StandardScaler_Epoch\nfrom moabb.utils import setup_seed\n\n\nset_log_level(\"info\")" | ||
] | ||
}, | ||
{ | ||
|
@@ -98,7 +98,7 @@ | |
}, | ||
"outputs": [], | ||
"source": [ | ||
"# Set EEG Inception model\nmodel = EEGInception(in_channels=22, n_classes=2)\n\n# Hyperparameter\nLEARNING_RATE = 0.0001\nWEIGHT_DECAY = 0\nBATCH_SIZE = 64\nSEED = 42\nVERBOSE = 1\nEPOCH = 2\nPATIENCE = 3\n\n# Define a Skorch classifier\nclf = EEGClassifier(\n module=model,\n criterion=torch.nn.CrossEntropyLoss,\n optimizer=torch.optim.Adam,\n optimizer__lr=LEARNING_RATE,\n batch_size=BATCH_SIZE,\n max_epochs=EPOCH,\n train_split=ValidSplit(0.2, random_state=SEED),\n callbacks=[\n EarlyStopping(monitor=\"valid_loss\", patience=PATIENCE),\n EpochScoring(\n scoring=\"accuracy\", on_train=True, name=\"train_acc\", lower_is_better=False\n ),\n EpochScoring(\n scoring=\"accuracy\", on_train=False, name=\"valid_acc\", lower_is_better=False\n ),\n InputShapeSetterEEG(\n params_list=[\"in_channels\", \"input_window_samples\", \"n_classes\"],\n ),\n ],\n verbose=VERBOSE, # Not printing the results for each epoch\n)\n\nclf.initialize()\n\nf_params = \"./results/Models_CrossSession/BNCI2014-001/1/braindecode_EEGInception/EEGInception_fitted_best_model.pkl\"\nf_optimizer = \"./results/Models_CrossSession/BNCI2014-001/1/braindecode_EEGInception/EEGInception_fitted_best_optim.pkl\"\nf_history = \"./results/Models_CrossSession/BNCI2014-001/1/braindecode_EEGInception/EEGInception_fitted_best_history.json\"\n\nclf.load_params(f_params=f_params, f_optimizer=f_optimizer, f_history=f_history)\n\n# Create the dataset\ncreate_dataset = BraindecodeDatasetLoader(drop_last_window=False)\n\n# Create the pipelines\npipes_pytorch = Pipeline([(\"Braindecode_dataset\", create_dataset), (\"EEGInception\", clf)])" | ||
"# Hyperparameter\nLEARNING_RATE = 0.0001\nWEIGHT_DECAY = 0\nBATCH_SIZE = 64\nSEED = 42\nVERBOSE = 1\nEPOCH = 2\nPATIENCE = 3\n\n# Define a Skorch classifier\nclf = EEGClassifier(\n module=EEGInception,\n optimizer=torch.optim.Adam,\n optimizer__lr=LEARNING_RATE,\n batch_size=BATCH_SIZE,\n max_epochs=EPOCH,\n train_split=ValidSplit(0.2, random_state=SEED),\n callbacks=[\n EarlyStopping(monitor=\"valid_loss\", patience=PATIENCE),\n EpochScoring(\n scoring=\"accuracy\", on_train=True, name=\"train_acc\", lower_is_better=False\n ),\n EpochScoring(\n scoring=\"accuracy\", on_train=False, name=\"valid_acc\", lower_is_better=False\n ),\n ],\n verbose=VERBOSE, # Not printing the results for each epoch\n)\n\nclf.initialize()\n\nf_params = \"./results/Models_CrossSession/BNCI2014-001/1/braindecode_EEGInception/EEGInception_fitted_best_model.pkl\"\nf_optimizer = \"./results/Models_CrossSession/BNCI2014-001/1/braindecode_EEGInception/EEGInception_fitted_best_optim.pkl\"\nf_history = \"./results/Models_CrossSession/BNCI2014-001/1/braindecode_EEGInception/EEGInception_fitted_best_history.json\"\n\nclf.load_params(f_params=f_params, f_optimizer=f_optimizer, f_history=f_history)\n\n# Create the pipelines\npipes_pytorch = make_pipeline(clf)" | ||
] | ||
} | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+0 Bytes
(100%)
docs/_downloads/97a1de59bce682890841bb846e3dd09c/auto_tutorials_jupyter.zip
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+0 Bytes
(100%)
docs/_downloads/cab7a090c4183ca69dc0cd84d3b04413/auto_tutorials_python.zip
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+120 Bytes
(100%)
docs/_images/sphx_glr_plot_benchmark_braindecode_thumb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.04 KB
(100%)
docs/_images/sphx_glr_plot_learning_curve_motor_imagery_001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+468 Bytes
(100%)
docs/_images/sphx_glr_plot_learning_curve_motor_imagery_thumb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+798 Bytes
(100%)
docs/_images/sphx_glr_plot_learning_curve_p300_external_001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+100 Bytes
(100%)
docs/_images/sphx_glr_plot_learning_curve_p300_external_thumb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1 Byte
(100%)
docs/_images/sphx_glr_tutorial_3_benchmarking_multiple_pipelines_001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+3 Bytes
(100%)
docs/_images/sphx_glr_tutorial_3_benchmarking_multiple_pipelines_thumb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.