Skip to content

Commit a1b57b8

Browse files
1 parent 2d06eed commit a1b57b8

302 files changed

Lines changed: 13355 additions & 4745 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dev/.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: fb11c39ac11c25e5dc07edcd12266e18
3+
config: 3dc9db1f0f951d39f882ba727f0a7312
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

dev/CNAME

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
braindecode.org
Binary file not shown.

dev/_downloads/1f2407fc0459906c808c847bdcd84ccf/plot_sleep_staging_eldele2021.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
# ~~~~~~~~~~~~~~~
6868
#
6969
# We extract 30-s windows to be used in the classification task.
70-
# The :class:`braindecode.models.SleepStagerEldele2021` model takes a
70+
# The :class:`braindecode.models.AttnSleep` model takes a
7171
# single channel as input. Here, the Fpz-Cz channel is used as it
7272
# was found to give better performance than using the Pz-Oz channel
7373

@@ -190,7 +190,7 @@ def get_center_label(x):
190190
import torch
191191
from torch import nn
192192

193-
from braindecode.models import SleepStagerEldele2021
193+
from braindecode.models import AttnSleep
194194
from braindecode.modules import TimeDistributed
195195
from braindecode.util import set_random_seeds
196196

@@ -205,8 +205,8 @@ def get_center_label(x):
205205
# Extract number of channels and time steps from dataset
206206
n_channels, input_size_samples = train_set[0][0].shape
207207

208-
feat_extractor = SleepStagerEldele2021(
209-
sfreq,
208+
feat_extractor = AttnSleep(
209+
sfreq=sfreq,
210210
n_outputs=n_classes,
211211
n_times=input_size_samples,
212212
return_feats=True,
Binary file not shown.
Binary file not shown.

dev/_downloads/3862cafd7f0d815e434319ffe525afc8/plot_bcic_iv_2a_moabb_cropped.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"cell_type": "markdown",
1212
"metadata": {},
1313
"source": [
14-
"Building on the `Trialwise Decoding <bcic-iv-2a-moabb-trial>`,\nwe now do more data-efficient cropped decoding!\n\nIn Braindecode, there are two supported configurations created for\ntraining models: trialwise decoding and cropped decoding. We will\nexplain this visually by comparing trialwise to cropped decoding.\n\n<img src=\"file://_static/trialwise_explanation.png\" alt=\"Trialwise decoding\">\n<img src=\"file://_static/cropped_explanation.png\" alt=\"Cropped decoding\">\n\nOn the left, you see trialwise decoding:\n\n1. A complete trial is pushed through the network.\n2. The network produces a prediction.\n3. The prediction is compared to the target (label) for that trial to\n compute the loss.\n\nOn the right, you see cropped decoding:\n\n1. Instead of a complete trial, crops are pushed through the network.\n2. For computational efficiency, multiple neighbouring crops are pushed\n through the network simultaneously (these neighbouring crops are\n called compute windows)\n3. Therefore, the network produces multiple predictions (one per crop in\n the window)\n4. The individual crop predictions are *AVERAGED* before computing the\n loss function\n\nThis averaging of predictions of small sub-windows is the key difference\nbetween trialwise and cropped decoding. It was introduced in [1]_ and it impact\non the parameters of the network.\n\nIt is important to note that the averaging of predictions is only done\nduring training. During testing, the network is still applied to crops\nand the predictions are averaged afterwards.\n\n\n<div class=\"alert alert-info\"><h4>Note</h4><p>- The network architecture implicitly defines the crop size (it is the\n receptive field size, i.e., the number of timesteps the network uses\n to make a single prediction)\n - The window size is a user-defined hyperparameter, called\n ``n_times`` in Braindecode. It mostly affects runtime\n (larger window sizes should be faster). As a rule of thumb, you can\n set it to two times the crop size.\n - Crop size and window size together define how many predictions the\n network makes per window: ``#window \u2212 #crop + 1 = #predictions``</p></div>\n\n<div class=\"alert alert-info\"><h4>Note</h4><p>For cropped decoding, the above training setup is mathematically\n similar to sampling crops in your dataset, pushing them through the\n network and training directly on the individual crops. However, the\n if their position would be randomly selected, the crops would be less\n correlated in contrast to the neighbourhood crops selected from a window.\n At the same time, the above training setup is much faster as it avoids\n redundant computations by using dilated convolutions, see [2]_.\n However, the two setups are only mathematically related in case (1)\n your network does not use any padding or only left padding and\n (2) your loss function leads\n to the same gradients when using the averaged output. The first is true\n for our shallow and deep ConvNet models and the second is true for the\n log-softmax outputs and negative log likelihood loss that is typically\n used for classification in PyTorch.</p></div>\n\n"
14+
"Building on the `Trialwise Decoding <bcic-iv-2a-moabb-trial>`,\nwe now do more data-efficient cropped decoding!\n\nIn Braindecode, there are two supported configurations created for\ntraining models: trialwise decoding and cropped decoding. We will\nexplain this visually by comparing trialwise to cropped decoding.\n\n<img src=\"file://_static/trialwise_explanation.png\" alt=\"Trialwise decoding\">\n<img src=\"file://_static/cropped_explanation.png\" alt=\"Cropped decoding\">\n\nOn the left, you see trialwise decoding:\n\n1. A complete trial is pushed through the network.\n2. The network produces a prediction.\n3. The prediction is compared to the target (label) for that trial to\n compute the loss.\n\nOn the right, you see cropped decoding:\n\n1. Instead of a complete trial, crops are pushed through the network.\n2. For computational efficiency, multiple neighbouring crops are pushed\n through the network simultaneously (these neighbouring crops are\n called compute windows)\n3. Therefore, the network produces multiple predictions (one per crop in\n the window)\n4. The individual crop predictions are *AVERAGED* before computing the\n loss function\n\nThis averaging of predictions of small sub-windows is the key difference\nbetween trialwise and cropped decoding. It was introduced in [1]_ and it impact\non the parameters of the network.\n\nIt is important to note that the averaging of predictions is only done\nduring training. During testing, the network is still applied to crops\nand the predictions are averaged afterwards.\n\n\n<div class=\"alert alert-info\"><h4>Note</h4><p>- The network architecture implicitly defines the crop size (it is the\n receptive field size, i.e., the number of timesteps the network uses\n to make a single prediction)\n - The window size is a user-defined hyperparameter, called\n ``n_times`` in Braindecode. It mostly affects runtime\n (larger window sizes should be faster). As a rule of thumb, you can\n set it to two times the crop size.\n - Crop size and window size together define how many predictions the\n network makes per window: ``#window - #crop + 1 = #predictions``</p></div>\n\n<div class=\"alert alert-info\"><h4>Note</h4><p>For cropped decoding, the above training setup is mathematically\n similar to sampling crops in your dataset, pushing them through the\n network and training directly on the individual crops. However, the\n if their position would be randomly selected, the crops would be less\n correlated in contrast to the neighbourhood crops selected from a window.\n At the same time, the above training setup is much faster as it avoids\n redundant computations by using dilated convolutions, see [2]_.\n However, the two setups are only mathematically related in case (1)\n your network does not use any padding or only left padding and\n (2) your loss function leads\n to the same gradients when using the averaged output. The first is true\n for our shallow and deep ConvNet models and the second is true for the\n log-softmax outputs and negative log likelihood loss that is typically\n used for classification in PyTorch.</p></div>\n\n"
1515
]
1616
},
1717
{
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)