Skip to content

Instantly share code, notes, and snippets.

🚀
It is by will alone I set my mind in motion.

Alexander Veysov snakers4

🚀
It is by will alone I set my mind in motion.
View GitHub Profile
@snakers4
snakers4 / warp_ctc_patch_cuda_10_1.patch
Last active Jan 28, 2020
warp_ctc_patch_cuda_10_1
View warp_ctc_patch_cuda_10_1.patch
diff --git a/include/contrib/moderngpu/include/device/intrinsics.cuh b/include/contrib/moderngpu/include/device/intrinsics.cuh
index a601443..c212a38 100644
--- a/include/contrib/moderngpu/include/device/intrinsics.cuh
+++ b/include/contrib/moderngpu/include/device/intrinsics.cuh
@@ -112,7 +112,7 @@ __device__ __forceinline__ float shfl_up(float var,
unsigned int delta, int width = 32) {
#if __CUDA_ARCH__ >= 300
- var = __shfl_up(var, delta, width);
+ var = __shfl_up_sync(0xFFFFFFFF, var, delta, width);
@snakers4
snakers4 / modeling.py
Created Mar 1, 2019
Best pretraining for Russian language - embedding bag interfaces
View modeling.py
class BertEmbeddingBag(nn.Module):
"""Construct the embeddings from word, position and token_type embeddings.
"""
def __init__(self, config):
super(BertEmbeddingBag, self).__init__()
# self.word_embeddings = nn.Embedding(config.vocab_size, config.hidden_size)
ngram_matrix=np.load(config.ngram_matrix_path)
self.old_bag = config.old_bag
@snakers4
snakers4 / send_test_email.sh
Last active Feb 24, 2019
Plain temperature monitoring in Ubuntu 18.04
View send_test_email.sh
{
echo To: YOUR_EMAIL@gmail.com
echo From: YOUR_EMAIL@gmail.com
echo Subject: Temperature warning! $TIMESTAMP
echo Current CPU temperature is $TEMP
} | ssmtp YOUR_EMAIL@gmail.com
@snakers4
snakers4 / pandas_multiprocessing_wrappers.py
Created Dec 14, 2018
Pandas multiprocessing wrappers
View pandas_multiprocessing_wrappers.py
from tqdm import tqdm
import numpy as np
import pandas as pd
from multiprocessing import Pool
def _apply_df(args):
df, func, num, kwargs = args
return num, df.apply(func, **kwargs)
def apply_by_multiprocessing(df,func,**kwargs):
@snakers4
snakers4 / parse_cc_index.py
Last active Dec 20, 2019
Plain common crawl pre-processing
View parse_cc_index.py
import gc
import gzip
import time
import json
import shutil
import os,sys
import tldextract
import collections
import pandas as pd
from tqdm import tqdm
@snakers4
snakers4 / parse_cc_index.py
Last active Jun 12, 2020
Plain scripts to parse Common Crawl
View parse_cc_index.py
import gc
import gzip
import time
import json
import shutil
import os,sys
import tldextract
import collections
import pandas as pd
from tqdm import tqdm
@snakers4
snakers4 / process_wikipedia.py
Last active Jul 15, 2020
Post process wikipedia files produced by wikiextractor
View process_wikipedia.py
import os
import re
import sys
import glob
import nltk
import gensim
import numpy as np
import pandas as pd
from tqdm import tqdm
from uuid import uuid4
@snakers4
snakers4 / calculate_knn.py
Created Aug 26, 2018
Use faiss to calculate a KNN graph on data
View calculate_knn.py
import gc
import tqdm
import faiss
import bcolz
import os,sys
import numpy as np
from tqdm import tqdm
# open the stored bcolz array
# note that these vectors have to be 280 dimensional
@snakers4
snakers4 / Loss.py
Created Jul 21, 2018
Multi class classification focal loss
View Loss.py
import torch
import torch.nn as nn
import torch.nn.functional as F
# Focal loss implementation inspired by
# https://github.com/c0nn3r/RetinaNet/blob/master/focal_loss.py
# https://github.com/doiken23/pytorch_toolbox/blob/master/focalloss2d.py
class MultiClassBCELoss(nn.Module):
def __init__(self,
use_weight_mask=False,
@snakers4
snakers4 / train.sh
Created Jul 7, 2018
VAE explanation bits
View train.sh
python3 train.py \
--epochs 30 --batch-size 512 --seed 42 \
--model_type fc_conv --dataset_type fmnist --latent_space_size 10 \
--do_augs False \
--lr 1e-3 --m1 40 --m2 50 \
--optimizer adam \
--do_running_mean False --img_loss_weight 1.0 --kl_loss_weight 1.0 \
--image_loss_type bce --ssim_window_size 5 \
--print-freq 10 \
--lognumber fmnist_fc_conv_l10_rebalance_no_norm \
You can’t perform that action at this time.