Skip to content

Instantly share code, notes, and snippets.

View jinglescode's full-sized avatar
🎯
stay focus

Hong Jing (Jingles) jinglescode

🎯
stay focus
View GitHub Profile
class TestConv1d(nn.Module):
def __init__(self):
super(TestConv1d, self).__init__()
self.conv = nn.Conv1d(in_channels=1, out_channels=1, kernel_size=3, stride=3, bias=False)
self.init_weights()
def forward(self, x):
return self.conv(x)
def init_weights(self):
class TestConv1d(nn.Module):
def __init__(self):
super(TestConv1d, self).__init__()
self.conv = nn.Conv1d(in_channels=1, out_channels=1, kernel_size=5, padding=2, bias=False)
self.init_weights()
def forward(self, x):
return self.conv(x)
def init_weights(self):
class TestConv1d(nn.Module):
def __init__(self):
super(TestConv1d, self).__init__()
self.conv = nn.Conv1d(in_channels=1, out_channels=1, kernel_size=3, padding=1, bias=False)
self.init_weights()
def forward(self, x):
return self.conv(x)
def init_weights(self):
class TestConv1d(nn.Module):
def __init__(self):
super(TestConv1d, self).__init__()
self.conv = nn.Conv1d(in_channels=1, out_channels=1, kernel_size=3, bias=False)
self.init_weights()
def forward(self, x):
return self.conv(x)
def init_weights(self):
class TestConv1d(nn.Module):
def __init__(self):
super(TestConv1d, self).__init__()
self.conv = nn.Conv1d(in_channels=1, out_channels=1, kernel_size=2, bias=False)
self.init_weights()
def forward(self, x):
return self.conv(x)
def init_weights(self):
class TestConv1d(nn.Module):
def __init__(self):
super(TestConv1d, self).__init__()
self.conv = nn.Conv1d(in_channels=1, out_channels=1, kernel_size=1, bias=False)
self.init_weights()
def forward(self, x):
return self.conv(x)
def init_weights(self):
import numpy as np
import matplotlib.pyplot as plt
def generate_signal(length_seconds, sampling_rate, frequencies_list, func="sin", add_noise=0, plot=True):
r"""
Generate a `length_seconds` seconds signal at `sampling_rate` sampling rate. See torchsignal (https://github.com/jinglescode/torchsignal) for more info.
Args:
length_seconds : int
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import torch
from torch import nn
class MultitaskSSVEP(nn.Module):
"""
Using multi-task learning to capture signals simultaneously from the fovea efficiently and the neighboring targets in the peripheral vision generate a visual response map. A calibration-free user-independent solution, desirable for clinical diagnostics. A stepping stone for an objective assessment of glaucoma patients’ visual field.
Learn more about this model at https://jinglescode.github.io/ssvep-multi-task-learning/
This model is a multi-label model. Although it produces multiple outputs, we also used this model to get our multi-class results in our paper.
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import TransformerEncoder, TransformerEncoderLayer
class TransformerModel(nn.Module):
def __init__(self, ntoken, ninp, nhead, nhid, nlayers, dropout=0.5):