Navigation Menu

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
#https://gist.github.com/keunwoochoi/be18701219fb671f6c74b3d6e0740513
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):
super().__init__()
self.conv = nn.Conv1d(in_dim, out_dim, kernel_size=kernel_size, padding=padding, stride=stride)
self.bn = nn.BatchNorm1d(out_dim)
self.relu = nn.SiLU(inplace=True)
if pool is None:
self.pool=nn.Identity()
else:
@hengck23
hengck23 / gist:d3eb40d9b5bae7d08d3e12f26c84b0d7
Last active February 25, 2022 11:37
transformer fast decoder
from common import *
# https://scale.com/blog/pytorch-improvements
# Making Pytorch Transformer Twice as Fast on Sequence Generation.
# https://towardsdatascience.com/how-to-code-the-transformer-in-pytorch-24db27c8f9ec
class FeedForward(nn.Module):
def __init__(self, dim, ff_dim=2048, dropout=0.1):
super().__init__()
self.linear1 = nn.Linear(dim, ff_dim)
@hengck23
hengck23 / model.py
Last active September 17, 2020 09:06
model
from common import *
num_class = 266
# https://github.com/qiuqiangkong/audioset_tagging_cnn/blob/8d9999d72b282d2dc50a5b5f668dd91369f853c5/pytorch/models.py
# https://www.kaggle.com/hidehisaarai1213/introduction-to-sound-event-detection
# https://github.com/qiuqiangkong/sed_from_wekaly_labelled_data/blob/master/spectrogram_to_wave.py
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):