sssm.sssm_core.model#

Classes#

Config

Context_Cont_configs

Model

Mixin class for all classifiers in scikit-learn.

TC

augmentations

base_Model

Base class for all neural network modules.

Module Contents#

class sssm.sssm_core.model.Config[source]#

Bases: object

Context_Cont[source]#
TC[source]#
augmentation[source]#
batch_size = 3500[source]#
beta1 = 0.9[source]#
beta2 = 0.99[source]#
drop_last = True[source]#
dropout = 0.35[source]#
features_len = 15[source]#
final_out_channels = 128[source]#
input_channels = 1[source]#
kernel_size = 25[source]#
lr = 0.0003[source]#
num_classes = 7[source]#
num_epoch = 50[source]#
optimizer = 'adam'[source]#
stride = 3[source]#
class sssm.sssm_core.model.Context_Cont_configs[source]#

Bases: object

temperature = 0.2[source]#
use_cosine_similarity = True[source]#
class sssm.sssm_core.model.Model(device='cuda', model_name='model.pt', model_path=None)[source]#

Bases: sklearn.base.ClassifierMixin, sklearn.base.BaseEstimator

Mixin class for all classifiers in scikit-learn.

This mixin defines the following functionality:

  • _estimator_type class attribute defaulting to “classifier”;

  • score method that default to accuracy_score().

  • enforce that fit requires y to be passed through the requires_y tag.

Read more in the User Guide.

Examples

>>> import numpy as np
>>> from sklearn.base import BaseEstimator, ClassifierMixin
>>> # Mixin classes should always be on the left-hand side for a correct MRO
>>> class MyEstimator(ClassifierMixin, BaseEstimator):
...     def __init__(self, *, param=1):
...         self.param = param
...     def fit(self, X, y=None):
...         self.is_fitted_ = True
...         return self
...     def predict(self, X):
...         return np.full(shape=X.shape[0], fill_value=self.param)
>>> estimator = MyEstimator(param=1)
>>> X = np.array([[1, 2], [2, 3], [3, 4]])
>>> y = np.array([1, 0, 1])
>>> estimator.fit(X, y).predict(X)
array([1, 1, 1])
>>> estimator.score(X, y)
0.66...
__load_model(model_path=None, model_name='model.pt')[source]#
__predict(data)[source]#
__rearrange_output(proba, fea, n_epoch)[source]#
__sliding_window_sample(X=None, step=50)[source]#
plot_predictions(epoch_ind=0)[source]#
predict(X=None, step=50)[source]#

input data, predict sleep event for each time step :param X: (n_epoch, n_time) :param step: 300 >= step >= 1 :return: predict_proba, pred, filtered pred, feature

predict_proba(X=None, step=50)[source]#

input data, predict sleep event for each time step :param X: (n_epoch, n_time) :param step: 300 >= step >= 1 :return: predict_proba, pred, filtered pred, feature

to_json()[source]#
to_pandas(overall_threshold=0.5, describe=False, event_threshold=None)[source]#
LABEL_LONG = ['Spindle', 'K-complex', 'Slow wave', 'Sawtooth', 'Vertex Sharp', 'Background', 'Arousal'][source]#
LABEL_SHORT = ['SS', 'KC', 'SW', 'SAW', 'VSW', 'BG', 'AR'][source]#
N_TIME = 300[source]#
device[source]#
feature = None[source]#
input_data_length = None[source]#
model[source]#
pred = None[source]#
proba = None[source]#
step = None[source]#
class sssm.sssm_core.model.TC[source]#

Bases: object

hidden_dim = 128[source]#
timesteps = 5[source]#
class sssm.sssm_core.model.augmentations[source]#

Bases: object

jitter_ratio = 2[source]#
jitter_scale_ratio = 1.5[source]#
max_seg = 12[source]#
class sssm.sssm_core.model.base_Model(configs)[source]#

Bases: torch.nn.Module

Base class for all neural network modules.

Your models should also subclass this class.

Modules can also contain other Modules, allowing to nest them in a tree structure. You can assign the submodules as regular attributes:

import torch.nn as nn
import torch.nn.functional as F

class Model(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = nn.Conv2d(1, 20, 5)
        self.conv2 = nn.Conv2d(20, 20, 5)

    def forward(self, x):
        x = F.relu(self.conv1(x))
        return F.relu(self.conv2(x))

Submodules assigned in this way will be registered, and will have their parameters converted too when you call to(), etc.

Note

As per the example above, an __init__() call to the parent class must be made before assignment on the child.

Variables:

training (bool) – Boolean represents whether this module is in training or evaluation mode.

forward(x_in)[source]#
conv_block1[source]#
conv_block2[source]#
conv_block3[source]#
logits[source]#
model_output_dim[source]#