braindecode 0.2.0__tar.gz → 0.2.1__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-0.2.0 → Braindecode-0.2.1}/Braindecode.egg-info/PKG-INFO +1 -1
- {Braindecode-0.2.0 → Braindecode-0.2.1}/PKG-INFO +1 -1
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/torch_ext/losses.py +9 -2
- Braindecode-0.2.1/braindecode/version.py +1 -0
- Braindecode-0.2.0/braindecode/version.py +0 -1
- {Braindecode-0.2.0 → Braindecode-0.2.1}/Braindecode.egg-info/SOURCES.txt +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/Braindecode.egg-info/dependency_links.txt +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/Braindecode.egg-info/not-zip-safe +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/Braindecode.egg-info/requires.txt +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/Braindecode.egg-info/top_level.txt +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/LICENSE.txt +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/MANIFEST.in +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/README.rst +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/__init__.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/datasets/__init__.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/datasets/bbci.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/datasets/bcic_iv_2a.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/datasets/multiple.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/datasets/sensor_positions.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/datautil/__init__.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/datautil/iterators.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/datautil/signal_target.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/datautil/signalproc.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/datautil/splitters.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/datautil/trial_segment.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/datautil/util.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/experiments/__init__.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/experiments/experiment.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/experiments/monitors.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/experiments/stopcriteria.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/mne_ext/__init__.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/mne_ext/signalproc.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/models/__init__.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/models/deep4.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/models/eegnet.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/models/shallow_fbcsp.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/models/util.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/torch_ext/__init__.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/torch_ext/constraints.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/torch_ext/functions.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/torch_ext/init.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/torch_ext/modules.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/torch_ext/util.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/util.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/visualization/__init__.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/visualization/perturbation.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/braindecode/visualization/plot.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/docs/Makefile +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/docs/conf.py +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/docs/index.rst +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/docs/notebooks/BBCI_Data.ipynb +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/docs/notebooks/BBCI_Data_Start_Stop.ipynb +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/docs/notebooks/BBCI_Data_Trialwise.ipynb +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/docs/notebooks/Cropped_Decoding.ipynb +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/docs/notebooks/Experiment_Class.ipynb +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/docs/notebooks/TrialWise_Decoding.ipynb +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/docs/notebooks/visualization/Perturbation.ipynb +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/docs/source/braindecode.datasets.rst +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/docs/source/braindecode.datautil.rst +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/docs/source/braindecode.experiments.rst +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/docs/source/braindecode.mne_ext.rst +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/docs/source/braindecode.models.rst +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/docs/source/braindecode.rst +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/docs/source/braindecode.torch_ext.rst +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/docs/source/braindecode.visualization.rst +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/docs/source/modules.rst +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/setup.cfg +0 -0
- {Braindecode-0.2.0 → Braindecode-0.2.1}/setup.py +0 -0
|
@@ -33,7 +33,7 @@ def log_categorical_crossentropy_1_hot(logpreds, targets, dims=None):
|
|
|
33
33
|
return result
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
def log_categorical_crossentropy(log_preds, targets):
|
|
36
|
+
def log_categorical_crossentropy(log_preds, targets, class_weights=None):
|
|
37
37
|
"""
|
|
38
38
|
Returns log categorical crossentropy for given log-predictions and targets.
|
|
39
39
|
|
|
@@ -47,6 +47,8 @@ def log_categorical_crossentropy(log_preds, targets):
|
|
|
47
47
|
log_preds: torch.autograd.Variable`
|
|
48
48
|
Logarithm of softmax output.
|
|
49
49
|
targets: `torch.autograd.Variable`
|
|
50
|
+
class_weights: list of int, optional
|
|
51
|
+
Weights given to loss of different classes
|
|
50
52
|
|
|
51
53
|
Returns
|
|
52
54
|
-------
|
|
@@ -54,6 +56,8 @@ def log_categorical_crossentropy(log_preds, targets):
|
|
|
54
56
|
loss: `torch.autograd.Variable`
|
|
55
57
|
"""
|
|
56
58
|
if log_preds.size() == targets.size():
|
|
59
|
+
assert class_weights is None, (
|
|
60
|
+
"Class weights not implemented for one-hot")
|
|
57
61
|
return log_categorical_crossentropy_1_hot(log_preds, targets)
|
|
58
62
|
n_classes = log_preds.size()[1]
|
|
59
63
|
n_elements = 0
|
|
@@ -62,7 +66,10 @@ def log_categorical_crossentropy(log_preds, targets):
|
|
|
62
66
|
mask = targets == i_class
|
|
63
67
|
mask = mask.type_as(log_preds)
|
|
64
68
|
n_elements -= th.sum(mask)
|
|
65
|
-
|
|
69
|
+
this_loss = th.sum(mask * log_preds[:,i_class])
|
|
70
|
+
if class_weights is not None:
|
|
71
|
+
this_loss = this_loss * class_weights[i_class]
|
|
72
|
+
losses.append(this_loss)
|
|
66
73
|
return th.sum(th.stack(losses)) / n_elements
|
|
67
74
|
|
|
68
75
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.1"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|