Skip to content

Instantly share code, notes, and snippets.

View back2yes's full-sized avatar
🎯
Focusing

back2yes

🎯
Focusing
View GitHub Profile
@back2yes
back2yes / sinc_interpolation.py
Created March 29, 2024 07:59 — forked from fschwar4/sinc_interpolation.py
Fast Python implementation of Whittaker–Shannon / sinc / bandlimited interpolation.
import numpy as np
from numpy.typing import NDArray
def sinc_interpolation(x: NDArray, s: NDArray, u: NDArray) -> NDArray:
"""Whittaker–Shannon or sinc or bandlimited interpolation.
Args:
x (NDArray): signal to be interpolated, can be 1D or 2D
s (NDArray): time points of x (*s* for *samples*)
u (NDArray): time points of y (*u* for *upsampled*)
@back2yes
back2yes / glibc.md
Created April 26, 2022 08:39 — forked from wagenet/glibc.md
glibc Versions

glibc Versions

List of oldest supported version of top 10 Linux Distros and their glibc version according to distrowatch.com.

Summary

Out of all versions with published EOLs, 2.12 is the oldest glibc still active, found in CentOS 6.8.

If CentOS 6 and 7 are eliminated, the oldest glibc is 2.23 in Ubuntu and Slackware.

@back2yes
back2yes / seed_everything.py
Created February 13, 2022 13:43 — forked from ihoromi4/seed_everything.py
pytorch - set seed everything
def seed_everything(seed: int):
import random, os
import numpy as np
import torch
random.seed(seed)
os.environ['PYTHONHASHSEED'] = str(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
@back2yes
back2yes / Fleishman.py
Created February 3, 2022 17:45 — forked from paddymccrudden/Fleishman.py
Generate data with given mean, standard deviation, skew, and kurtosis. Intended for monte carlo simulations with non normal distributions
import numpy as np
from numpy.linalg import solve
import logging
logging.basicConfig(level = logging.DEBUG)
from scipy.stats import moment,norm
def fleishman(b, c, d):
"""calculate the variance, skew and kurtois of a Fleishman distribution
F = -c + bZ + cZ^2 + dZ^3, where Z ~ N(0,1)
"""
@back2yes
back2yes / Fleishman.py
Created February 3, 2022 17:29 — forked from zeimusu/Fleishman.py
Generate data with given mean, standard deviation, skew, and kurtosis. Intended for monte carlo simulations with non normal distributions
import numpy as np
from numpy.linalg import solve
import logging
logging.basicConfig(level = logging.DEBUG)
from scipy.stats import moment,norm
def fleishman(b, c, d):
"""calculate the variance, skew and kurtois of a Fleishman distribution
F = -c + bZ + cZ^2 + dZ^3, where Z ~ N(0,1)
"""
# This xorg configuration file will start a dummy X11 server.
# move it to /etc/X11/xorg.conf
# don't forget apt install xserver-xorg-video-dummy;
# based on https://xpra.org/Xdummy.html
Section "ServerFlags"
Option "DontVTSwitch" "true"
Option "AllowMouseOpenFail" "true"
Option "PciForceNone" "true"
Option "AutoEnableDevices" "false"
@back2yes
back2yes / drivertest.cpp
Created April 10, 2019 13:53 — forked from tautologico/drivertest.cpp
Vector addition example using CUDA driver API
/*
* drivertest.cpp
* Vector addition (host code)
*
* Andrei de A. Formiga, 2012-06-04
*/
#include <stdio.h>
#include <stdlib.h>
/home/x/TensorComprehensions
Build Type: Release
Building ALL
gflags found
glog found
PyTorch is installed, libATen.so will be used from there to avoid two copies
isl found
Successfully installed DLPACK
no files found
# Archive together all the halide and llvm object files
@back2yes
back2yes / lc.py
Created March 27, 2018 08:32 — forked from guillefix/lc.py
temporal workaround to get Conv2dLocal to work in PyTorch
# coding: utf-8
# In[1]:
import math
import torch
from torch.nn.parameter import Parameter
import torch.nn.functional as F
size of input: torch.Size([1, 4, 8, 8])
input:
(0 ,0 ,.,.) =
0.8782 -0.8192 -0.9739 -0.3594 -0.2563 0.1029 -1.8487 -0.3550
0.3321 0.0943 -0.3745 -0.6876 -0.0085 2.5286 2.0220 -0.5226
-1.3020 0.2146 0.5424 0.1033 2.4845 0.3598 1.5213 -0.1765
-0.6228 1.2918 0.3838 -1.2308 1.9327 0.1885 -0.3766 -0.0046
-0.3527 -0.7072 0.7443 -1.0632 -0.0488 0.7710 1.0156 -2.0560
0.3643 -0.0037 -0.9849 -0.3245 -0.0614 -0.4680 0.4322 -2.1684
-0.9470 -0.7947 1.5997 -0.5201 -0.4490 -0.5583 0.0956 -0.4794