Skip to content

Instantly share code, notes, and snippets.

@bkj
bkj / ablr.py
Last active January 19, 2024 23:37
#!/usr/bin/env python
"""
ablr.py
"""
import numpy as np
import torch
from torch import nn
"""
openml_rerf_test.py
"""
import sys
import openml
import argparse
import numpy as np
import pandas as pd
from multiprocessing import Process
from time import time
import numpy as np
from exline.helpers import with_timeout
from sklearn.svm import SVC
def __SVC_fit(model, X, y, out):
out['result'] = model.fit(X, y)
#!/usr/bin/env python
"""
timed_parmap.py
"""
import sys
from joblib import delayed
from concurrent.futures import ProcessPoolExecutor, as_completed
#!/usr/bin/env python
"""
faiss_svc.py
"""
import faiss
import numpy as np
from time import time
from sklearn.svm import LinearSVC
@bkj
bkj / bohb.py
Last active February 16, 2019 22:38
#!/usr/bin/env python
"""
bohb.py
"""
import numpy as np
from uuid import uuid4
import ConfigSpace as CS
@bkj
bkj / bce_loss.py
Last active February 14, 2019 17:44
formulas for BCE loss in pytorch
import pandas as pd
import torch.nn.functional as F
def sparse_bce_with_logits(x, i, j):
t1 = x.clamp(min=0).mean()
t2 = - x[(i, j)].sum() / x.numel()
t3 = torch.log(1 + torch.exp(-torch.abs(x))).mean()
return t1 + t2 + t3
@bkj
bkj / download_google_drive.sh
Created December 6, 2018 15:48
script to download large file from google drive programatically
#!/bin/bash
# download_google_drive.sh
function download_google_drive {
SRC=$1
DST=$2
echo "$SRC -> $DST"
curl -c /tmp/cookies "https://drive.google.com/uc?export=download&id=$SRC" > /tmp/intermezzo.html
#!/usr/bin/env python
"""
mtx2edgelist.py
"""
from scipy.io import mmread
import numpy as np
import pandas as pd
import argparse
#!/usr/bin/env python
"""
edgelist2mtx.py
"""
from scipy.io import mmwrite
import numpy as np
import pandas as pd