Skip to content

Instantly share code, notes, and snippets.

from common import *
from ventilator import *
import faiss
data_dir = root_dir+'/data'
train_df = pd.read_csv(data_dir + '/train.csv')
test_df = pd.read_csv(data_dir + '/test.csv')
if 1: #check statistics
from common import *
from scipy.signal import get_window
from scipy import signal
def next_pow2(x):
return int(np.ceil(np.log2(x)))
class ConvBn1d(nn.Module):
def __init__(self, in_dim, out_dim, kernel_size, padding, stride=1, pool=None):
self.conv = nn.Conv1d(in_dim, out_dim, kernel_size=kernel_size, padding=padding, stride=stride) = nn.BatchNorm1d(out_dim)
self.relu = nn.SiLU(inplace=True)
if pool is None:
hengck23 / gist:d3eb40d9b5bae7d08d3e12f26c84b0d7
Last active February 25, 2022 11:37
transformer fast decoder
from common import *
# Making Pytorch Transformer Twice as Fast on Sequence Generation.
class FeedForward(nn.Module):
def __init__(self, dim, ff_dim=2048, dropout=0.1):
self.linear1 = nn.Linear(dim, ff_dim)
hengck23 /
Last active September 17, 2020 09:06
from common import *
num_class = 266
class ConvBlock(nn.Module):
def __init__(self, in_channel, out_channel, pool_size=1):
super(ConvBlock, self).__init__()
from common import *
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from my_tabnet.sparsemax import Sparsemax
class Identity(torch.nn.Module):
def forward(self, x):