Skip to content

Instantly share code, notes, and snippets.

cudaError_t Core(int peer_ = 0)
{
// --
// Alias variables
auto &data_slice = this -> enactor ->
problem -> data_slices[this -> gpu_num][0];
auto &enactor_slice = this -> enactor ->
enactor_slices[this -> gpu_num * this -> enactor -> num_gpus + peer_];
#!/usr/bin/env python
"""
edgelist2mtx.py
"""
from scipy.io import mmwrite
import numpy as np
import pandas as pd
#!/usr/bin/env python
"""
mtx2edgelist.py
"""
from scipy.io import mmread
import numpy as np
import pandas as pd
import argparse
@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
@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 / 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
#!/usr/bin/env python
"""
faiss_svc.py
"""
import faiss
import numpy as np
from time import time
from sklearn.svm import LinearSVC
#!/usr/bin/env python
"""
timed_parmap.py
"""
import sys
from joblib import delayed
from concurrent.futures import ProcessPoolExecutor, as_completed
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)
"""
openml_rerf_test.py
"""
import sys
import openml
import argparse
import numpy as np
import pandas as pd