## 2 Materials and Methods
### Experiments  
To evaluate the benefits of the Bayesian approach to the BCI problem, we performed two sets of experiments. The first set was intended to check if BNNs can improve the generalization properties of neural networks commonly used in BCIs. The second set of experiments is intended to investigate the capability of BNNs to detect out-of-domain input data. For the experiments on the generalization properties of BNNs, we used the following procedure. For BNNs, we sampled four chains of weight samples, 40 samples each. In each chain, we discarded the first ten samples so that 120 weight samples in total were obtained. The burn-in phase consisted of 200 steps. The sampler was run with step length equal to 0.01 and momentum decay equal to 0.01. Each 200 th sample was saved to make predictions on a test set. These values were suggested by [PERSON] [33] for experiments on low-dimensional data. Deterministic, i.e., non-Bayesian versions of the same models, were used as a baseline. These models were trained on 350 epochs for EEGNet and 100 epochs for Shallow ConvNet. For both deterministic nets and their ensembles, we used the learning rate of 0.000625 and set the momentum decay value to zero, as recommended in Braindecode tutorials. The batch size was 288 and 64 for Bayesian and deterministic networks, respectively. The final prediction was an average across predictions of all samples or instances of the ensemble. The values of all hyperparameters are presented in Table 1.  
This experiment was conducted using all four classes of data and the BNNs of the same architectures with the settings specified above. The deterministic network architectures used in this experiment were single EEGNet and Shallow ConvNet networks using the settings mentioned above. These networks were fitted using the whole BCI competition IV 2a dataset without the exclusion of any classes. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Hyperparameter** & **BNN** & **Deterministic Ensembles** \\ \hline entry 1 & data & data \\ Number of chains & 4 & n/a \\ Weight samples in chain & 40 & n/a \\ Number of steps for burn-in phase & 200 & n/a \\ Step size & 0.01 & n/a \\ Sampling frequency & 200 & n/a \\ Number of first samples to be discarded & 10 & n/a \\ Number of epochs & n/a & 350 (EEGNetV4), 100 (Shallow ConvNet) \\ Batch size & 288 & 64 \\ Learning rate & n/a & 0.000625 \\ Momentum decay & 0.01 & 0.0 \\ Number of samples/networks & 120 & 120 \\ Temporal convolution size & \(1\times 64\) (EEGNetV4), \(25\times 1\) (Shallow ConvNet) & \(1\times 64\) (EEGNetV4), \(25\times 1\) (Shallow ConvNet) \\ Spatial convolution size & \(22\times 1\) (EEGNetV4), \(1\times 22\) (Shallow ConvNet) & \(22\times 1\) (EEGNetV4), \(1\times 22\) (Shallow ConvNet) \\ \hline \hline \end{tabular}
\end{table} 
Table 1: List of hyperparameters used for BNN and ensembles of deterministic neural networks. n/a stands for “not applicable”. In the OOD detection experiments, we maintained consistency with the first series of experiments by using the same inference and optimization procedures. This included using the same hyperparameter values, number of training and Bayesian inference epochs, and procedure of collecting weight samples from the posterior distribution. As was mentioned above, we used only 2 classes in training data: left and right-hand imaginary movement. We used ensembles of considered model architectures as a baseline in this experiment. Each ensemble contained 120 instances of deterministic models. The out-of-domain detection method for EEG data presented here is as follows. As the measure of uncertainty, the variance across the logits estimated by all samples or ensemble elements was used. Because the logit vector had 2 dimensions, we calculated its Euclidean norm to obtain a single value. The variance of BNN and ensemble predictions was collected on each data point in the test set.