Skip to content

Instantly share code, notes, and snippets.

@cycyyy
cycyyy / tiling_test.py
Created October 20, 2022 04:14
tiling_test.py
import numpy as np
from jax import random
from neural_tangents import stax
random_key = random.PRNGKey(42)
SAMPLE_SIZE = 100
BATCH_SIZE = 25
def get_mlp_kernel_fn():
import numpy as np
from sklearn.neighbors import NearestNeighbors
from scipy import spatial
import math
from multiprocessing.pool import Pool
import multiprocessing
def main(X, Y, k, alpha):
nbrs = NearestNeighbors(n_neighbors=k, algorithm='kd_tree').fit(X)
tree = spatial.KDTree(Y)
from collections import OrderedDict
from tqdm import tqdm
import torch.nn.functional as F
import torch.utils.data as td
from torch import nn
import torch
import numpy as np
from deepctr_torch.inputs import SparseFeat, DenseFeat
import os
import sys
from deepctr_torch.inputs import SparseFeat, DenseFeat
import numpy as np
import torch
from torch import nn
import torch.utils.data as td
import torch.nn.functional as F
from tqdm import tqdm
import sys
MAX = sys.maxsize
from deepctr_torch.inputs import SparseFeat, DenseFeat
import numpy as np
import torch
from torch import nn
import torch.utils.data as td
import torch.nn.functional as F
from tqdm import tqdm
import sys, os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
@cycyyy
cycyyy / error
Created December 23, 2020 00:52
[ 50%] Building CXX object CMakeFiles/recsys.dir/main.cpp.o
In file included from /usr/include/arrow/util/variant.h:20:0,
from /usr/include/arrow/type.h:34,
from /usr/include/parquet/properties.h:27,
from /usr/include/parquet/metadata.h:29,
from /usr/include/parquet/file_reader.h:26,
from /home/xxx/main.cpp:10:
/usr/include/arrow/vendored/variant.hpp:911:41: error: ‘lib’ has not been declared
struct variant_size<variant<Ts...>> : lib::size_constant<sizeof...(Ts)> {};
^~~
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(recsys)
find_package(Torch REQUIRED)
find_library(ROCKSDB_LIB rocksdb)
find_package(Boost 1.67.0 REQUIRED COMPONENTS system filesystem)
add_executable(recsys main.cpp)
target_link_libraries(recsys "${Boost_LIBRARIES}" "${ROCKSDB_LIB}") #It works fine
import numpy as np
import math
from scipy.spatial import distance
n = 2000
p = 800
r = 1000
print("r/n:", r/n)
print("p/n:", p/n)
print("theory result:", math.log(1+(n-p)/(r-p)))
@cycyyy
cycyyy / perf.c
Last active September 26, 2019 01:15
void PerfSampleWrap::signal_handler(int sig_num, siginfo_t *sig_info, void *context)
{
perf_event_mmap_page *mmap_buffer = (perf_event_mmap_page *) data->buffers[index];
while (__mmap_get_remain_size(mmap_buffer) > 0)
{
uint64_t remain = __mmap_get_remain_size(mmap_buffer);
if (remain < sizeof(perf_event_header))
{
__mmap_move_index(mmap_buffer, remain);
break;
0x7f0f2c33b740 __pyx_f_6mtrand_cont0_array /home/ychen/.local/lib/python3.6/site-packages/numpy/random/mtrand.cpython-36m-x86_64-linux-gnu.so
0x7f0f2c33d270 __pyx_pw_6mtrand_11RandomState_17random_sample /home/ychen/.local/lib/python3.6/site-packages/numpy/random/mtrand.cpython-36m-x86_64-linux-gnu.so
0x562330 PyCFunction_Call python3
0x7f0f2c31f360 __pyx_pw_6mtrand_11RandomState_29rand /home/ychen/.local/lib/python3.6/site-packages/numpy/random/mtrand.cpython-36m-x86_64-linux-gnu.so
0x4f83a0 PyEval_CallObjectWithKeywords python3
0x4f9460 arr1 = np.random.rand(size, size) ../python/num.py:8
0x4f5e40 PyEval_CallObjectWithKeywords python3
0x4f9000 PyEval_EvalCode python3
0x641580 PyParser_ASTFromFileObject python3
0x6415d0 PyRun_FileExFlags python3