FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
moabb/examples/plot_benchmark_DL.py at develop · goodcpp/moabb · GitHub
goodcpp
moabb
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
moabb
/
examples
/
plot_benchmark_DL.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
124 lines (108 loc) · 4.79 KB
Breadcrumbs
moabb
/
examples
/
plot_benchmark_DL.py
Copy path
File metadata and controls
124 lines (108 loc) · 4.79 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
"""
====================================================================
Benchmarking on MOABB with Tensorflow deep net architectures
====================================================================
This example shows how to use MOABB to benchmark a set of Deep Learning pipeline (Tensorflow)
on all available datasets.
For this example, we will use only one dataset to keep the computation time low, but this benchmark is designed
to easily scale to many datasets.
"""
# Authors: Igor Carrara <igor.carrara@inria.fr>
#
# License: BSD (3-clause)
import
os
import
matplotlib
.
pyplot
as
plt
import
tensorflow
as
tf
from
absl
.
logging
import
ERROR
,
set_verbosity
from
moabb
import
benchmark
,
set_log_level
from
moabb
.
analysis
.
plotting
import
score_plot
from
moabb
.
datasets
import
BNCI2014_001
from
moabb
.
utils
import
setup_seed
set_log_level
(
"info"
)
# Avoid output Warning
set_verbosity
(
ERROR
)
os
.
environ
[
"TF_CPP_MIN_LOG_LEVEL"
]
=
"3"
CPU
=
len
(
tf
.
config
.
list_physical_devices
(
"CPU"
))
>
0
print
(
"CPU is"
,
"AVAILABLE"
if
CPU
else
"NOT AVAILABLE"
)
GPU
=
len
(
tf
.
config
.
list_physical_devices
(
"GPU"
))
>
0
print
(
"GPU is"
,
"AVAILABLE"
if
GPU
else
"NOT AVAILABLE"
)
###############################################################################
# In this example, we will use only the dataset ``BNCI2014_001``.
#
# Running the benchmark
# ---------------------
#
# The benchmark is run using the ``benchmark`` function. You need to specify the
# folder containing the pipelines to use, the kind of evaluation and the paradigm
# to use. By default, the benchmark will use all available datasets for all
# paradigms listed in the pipelines. You could restrict to specific evaluation and
# paradigm using the ``evaluations`` and ``paradigms`` arguments.
#
# To save computation time, the results are cached. If you want to re-run the
# benchmark, you can set the ``overwrite`` argument to ``True``.
#
# It is possible to indicate the folder to cache the results and the one to save
# the analysis & figures. By default, the results are saved in the ``results``
# folder, and the analysis & figures are saved in the ``benchmark`` folder.
#
# This code is implemented to run on CPU. If you're using a GPU, do not use multithreading
# (i.e. set n_jobs=1)
# Set up reproducibility of Tensorflow
setup_seed
(
42
)
# Restrict this example only on the first two subject of BNCI2014_001
dataset
=
BNCI2014_001
()
dataset
.
subject_list
=
dataset
.
subject_list
[:
2
]
datasets
=
[
dataset
]
results
=
benchmark
(
pipelines
=
"./pipelines_DL"
,
evaluations
=
[
"WithinSession"
],
paradigms
=
[
"LeftRightImagery"
],
include_datasets
=
datasets
,
results
=
"./results/"
,
overwrite
=
False
,
plot
=
False
,
output
=
"./benchmark/"
,
n_jobs
=
-
1
,
)
###############################################################################
# The deep learning architectures implemented in MOABB are:
# - Shallow Convolutional Network [1]_
# - Deep Convolutional Network [1]_
# - EEGNet [2]_
# - EEGTCNet [3]_
# - EEGNex [4]_
# - EEGITNet [5]_
#
# Benchmark prints a summary of the results. Detailed results are saved in a
# pandas dataframe, and can be used to generate figures. The analysis & figures
# are saved in the ``benchmark`` folder.
score_plot
(
results
)
plt
.
show
()
##############################################################################
# References
# ----------
# .. [1] Schirrmeister, R. T., Springenberg, J. T., Fiederer, L. D. J.,
# Glasstetter, M., Eggensperger, K., Tangermann, M., ... & Ball, T. (2017).
# `Deep learning with convolutional neural networks for EEG decoding and
# visualization <https://doi.org/10.1002/hbm.23730>`_.
# Human brain mapping, 38(11), 5391-5420.
# .. [2] Lawhern, V. J., Solon, A. J., Waytowich, N. R., Gordon, S. M.,
# Hung, C. P., & Lance, B. J. (2018). `EEGNet: a compact convolutional neural
# network for EEG-based brain-computer interfaces.
# <https://doi.org/10.1088/1741-2552/aace8c>`_
# Journal of neural engineering, 15(5), 056013.
# .. [3] Ingolfsson, T. M., Hersche, M., Wang, X., Kobayashi, N., Cavigelli, L., &
# Benini, L. (2020, October). `EEG-TCNet: An accurate temporal convolutional
# network for embedded motor-imagery brain-machine interfaces.
# <https://doi.org/10.1109/SMC42975.2020.9283028>`_
# In 2020 IEEE International Conference on Systems, Man, and Cybernetics (SMC)
# (pp. 2958-2965). IEEE.
# .. [4] Chen, X., Teng, X., Chen, H., Pan, Y., & Geyer, P. (2022). `Toward reliable
# signals decoding for electroencephalogram: A benchmark study to EEGNeX.
# <https://doi.org/10.48550/arXiv.2207.12369>`_
# arXiv preprint arXiv:2207.12369.
# .. [5] Salami, A., Andreu-Perez, J., & Gillmeister, H. (2022). `EEG-ITNet: An
# explainable inception temporal convolutional network for motor imagery
# classification
# <https://doi.org/10.1109/ACCESS.2022.3161489>`_.
# IEEE Access, 10, 36672-36685.
Back
|
FazBrowse Home
|
New Git URL