This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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__() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |