This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Developed by Vladimir Fadeev | |
(https://github.com/kirlf) | |
Kazan, 2017 / 2020 | |
Python 3.7 | |
The result is uploaded in | |
https://commons.wikimedia.org/wiki/File:AdaptiveBeamForming.png | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# In[1]: | |
import math | |
import torch | |
from torch.nn.parameter import Parameter | |
import torch.nn.functional as F |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cudnn.h> | |
#include <cassert> | |
#include <cstdlib> | |
#include <iostream> | |
#include <opencv2/opencv.hpp> | |
#define checkCUDNN(expression) \ | |
{ \ | |
cudnnStatus_t status = (expression); \ | |
if (status != CUDNN_STATUS_SUCCESS) { \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Resample.py | |
# Andrew Brock, 2017 | |
# This code resamples a 3d grid using catmull-rom spline interpolation, and is GPU accelerated. | |
# Resample along the trailing dimension | |
# Assumes a more-than-1D array? Or just directly assumes a 3D array? we'll find out | |
# | |
# TODO: Some things could be shared (such as the mgrid call, which can presumably be done once? hmm) | |
# between resample1d calls. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Weight norm is now added to pytorch as a pre-hook, so use that instead :) | |
import torch | |
import torch.nn as nn | |
from torch.nn import Parameter | |
from functools import wraps | |
class WeightNorm(nn.Module): | |
append_g = '_g' | |
append_v = '_v' |
NewerOlder